Fixed: [ Issue 41 ] Reduce noise in Outline View
https://code.google.com/p/protobuf-dt/issues/detail?id=41

Imports and Options are grouped into parent nodes that are collapsed by default.
diff --git a/com.google.eclipse.protobuf.ui/icons/imports.gif b/com.google.eclipse.protobuf.ui/icons/imports.gif
new file mode 100644
index 0000000..b0e9130
--- /dev/null
+++ b/com.google.eclipse.protobuf.ui/icons/imports.gif
Binary files differ
diff --git a/com.google.eclipse.protobuf.ui/icons/option.gif b/com.google.eclipse.protobuf.ui/icons/option.gif
index 9d8c615..557ea83 100644
--- a/com.google.eclipse.protobuf.ui/icons/option.gif
+++ b/com.google.eclipse.protobuf.ui/icons/option.gif
Binary files differ
diff --git a/com.google.eclipse.protobuf.ui/icons/options.gif b/com.google.eclipse.protobuf.ui/icons/options.gif
new file mode 100644
index 0000000..bdef879
--- /dev/null
+++ b/com.google.eclipse.protobuf.ui/icons/options.gif
Binary files differ
diff --git a/com.google.eclipse.protobuf.ui/icons/protobuf.gif b/com.google.eclipse.protobuf.ui/icons/protobuf.gif
deleted file mode 100644
index 5f161d9..0000000
--- a/com.google.eclipse.protobuf.ui/icons/protobuf.gif
+++ /dev/null
Binary files differ
diff --git a/com.google.eclipse.protobuf.ui/src/com/google/eclipse/protobuf/ui/labeling/Images.java b/com.google.eclipse.protobuf.ui/src/com/google/eclipse/protobuf/ui/labeling/Images.java
index 7fe0ced..898e21d 100644
--- a/com.google.eclipse.protobuf.ui/src/com/google/eclipse/protobuf/ui/labeling/Images.java
+++ b/com.google.eclipse.protobuf.ui/src/com/google/eclipse/protobuf/ui/labeling/Images.java
@@ -28,6 +28,7 @@
 @Singleton
 public class Images {
 
+  private static final String GIF_EXTENSION = ".gif";
   private static final String DEFAULT_IMAGE = "empty.gif";
 
   private static final Map<Modifier, String> IMAGES_BY_MODIFIER = new HashMap<Modifier, String>();
@@ -47,22 +48,24 @@
     IMAGES_BY_TYPE.put(Message.class, "message.gif");
     IMAGES_BY_TYPE.put(Option.class, "option.gif");
     IMAGES_BY_TYPE.put(Package.class, "package.gif");
-    IMAGES_BY_TYPE.put(Protobuf.class, "protobuf.gif");
     IMAGES_BY_TYPE.put(Rpc.class, "rpc.gif");
     IMAGES_BY_TYPE.put(Service.class, "service.gif");
     IMAGES_BY_TYPE.put(Syntax.class, "syntax.gif");
   }
 
-  private static final List<String> STANDALONE_IMAGES = asList("extensions.gif");
+  private static final List<String> STANDALONE_IMAGES = asList("extensions.gif", "imports.gif", "options.gif");
 
   public String imageFor(Object o) {
+    if (o instanceof Keyword) {
+      Keyword k = (Keyword) o;
+      return imageFor(k);
+    }
     if (o instanceof Property) {
       Property p = (Property) o;
       return imageFor(p.getModifier());
     }
-    if (o instanceof Keyword) {
-      Keyword k = (Keyword) o;
-      return imageFor(k);
+    if (o instanceof String) {
+      return o + GIF_EXTENSION;
     }
     return imageFor(o.getClass());
   }
@@ -80,7 +83,7 @@
     Modifier m = Modifier.getByName(value);
     String image = IMAGES_BY_MODIFIER.get(m);
     if (image != null) return image;
-    String imageName = value + ".gif";
+    String imageName = value + GIF_EXTENSION;
     if (IMAGES_BY_TYPE.containsValue(imageName) || STANDALONE_IMAGES.contains(imageName)) return imageName;
     return DEFAULT_IMAGE;
   }
diff --git a/com.google.eclipse.protobuf.ui/src/com/google/eclipse/protobuf/ui/labeling/Labels.java b/com.google.eclipse.protobuf.ui/src/com/google/eclipse/protobuf/ui/labeling/Labels.java
index a13a9b1..189f736 100644
--- a/com.google.eclipse.protobuf.ui/src/com/google/eclipse/protobuf/ui/labeling/Labels.java
+++ b/com.google.eclipse.protobuf.ui/src/com/google/eclipse/protobuf/ui/labeling/Labels.java
@@ -8,14 +8,14 @@
  */
 package com.google.eclipse.protobuf.ui.labeling;
 
-import static com.google.eclipse.protobuf.scoping.ProtobufImportUriResolver.URI_PREFIX;
 import static org.eclipse.jface.viewers.StyledString.DECORATIONS_STYLER;
 
 import org.eclipse.jface.viewers.StyledString;
 
 import com.google.eclipse.protobuf.protobuf.*;
 import com.google.eclipse.protobuf.ui.util.Properties;
-import com.google.inject.*;
+import com.google.inject.Inject;
+import com.google.inject.Singleton;
 
 /**
  * Registry of commonly used text in the 'Protocol Buffer' editor.
@@ -44,10 +44,6 @@
       Property p = (Property) o;
       return labelFor(p);
     }
-    if (o instanceof Protobuf) {
-      Protobuf p = (Protobuf) o;
-      return labelFor(p);
-    }
     if (o instanceof Rpc) {
       Rpc r = (Rpc) o;
       return labelFor(r);
@@ -60,9 +56,7 @@
   }
 
   private Object labelFor(Import i) {
-    String uri = i.getImportURI();
-    if (uri == null || !uri.startsWith(URI_PREFIX)) return uri;
-    return uri.substring(URI_PREFIX.length());
+    return i.getImportURI();
   }
 
   private Object labelFor(Literal l) {
@@ -79,11 +73,6 @@
     return text;
   }
 
-  private Object labelFor(Protobuf p) {
-    // TODO show this text till I figure out how to hide 'Protobuf' node in outline view
-    return "Protocol Buffer";
-  }
-
   private Object labelFor(Rpc r) {
     StyledString text = new StyledString(r.getName());
     String types = String.format(" : %s > %s", messageName(r.getArgType()), messageName(r.getReturnType()));
diff --git a/com.google.eclipse.protobuf.ui/src/com/google/eclipse/protobuf/ui/outline/ProtobufOutlinePage.java b/com.google.eclipse.protobuf.ui/src/com/google/eclipse/protobuf/ui/outline/ProtobufOutlinePage.java
index 493b16b..6d26481 100644
--- a/com.google.eclipse.protobuf.ui/src/com/google/eclipse/protobuf/ui/outline/ProtobufOutlinePage.java
+++ b/com.google.eclipse.protobuf.ui/src/com/google/eclipse/protobuf/ui/outline/ProtobufOutlinePage.java
@@ -8,7 +8,17 @@
  */
 package com.google.eclipse.protobuf.ui.outline;
 
-import org.eclipse.xtext.ui.editor.outline.impl.OutlinePage;
+import static com.google.common.collect.Collections2.filter;
+import static com.google.common.collect.Lists.newArrayList;
+import static java.util.Collections.singletonList;
+
+import java.util.Collection;
+import java.util.List;
+
+import org.eclipse.xtext.ui.editor.outline.IOutlineNode;
+import org.eclipse.xtext.ui.editor.outline.impl.*;
+
+import com.google.common.base.Predicate;
 
 /**
  * Outline Page for Protocol Buffer editors.
@@ -17,11 +27,30 @@
  */
 public class ProtobufOutlinePage extends OutlinePage {
 
-  /**
-   * Indicates that the root node and its immediate children of the Outline View need to be expanded.
-   * @return 3.
-   */
-  @Override protected int getDefaultExpansionLevel() {
-    return 3;
+  @Override protected List<IOutlineNode> getInitiallyExpandedNodes() {
+    IOutlineNode rootNode = getTreeProvider().createRoot(getXtextDocument());
+    List<IOutlineNode> nodes = newArrayList(rootNode);
+    addChildrenToExpand(singletonList(rootNode), nodes, 3);
+    return nodes;
+  }
+
+  private void addChildrenToExpand(Collection<IOutlineNode> parents, List<IOutlineNode> nodes, int depth) {
+    if (depth < 1) return;
+    for (IOutlineNode parent : parents) {
+      Collection<IOutlineNode> children = childrenToExpand(parent);
+      nodes.addAll(children);
+      addChildrenToExpand(children, nodes, depth - 1);
+    }
+  }
+
+  private Collection<IOutlineNode> childrenToExpand(IOutlineNode parent) {
+    if (parent instanceof DocumentRootNode) {
+      return filter(parent.getChildren(), new Predicate<IOutlineNode>() {
+        public boolean apply(IOutlineNode node) {
+          return !(node instanceof EStructuralFeatureNode);
+        }
+      });
+    }
+    return parent.getChildren();
   }
 }
diff --git a/com.google.eclipse.protobuf.ui/src/com/google/eclipse/protobuf/ui/outline/ProtobufOutlineTreeProvider.java b/com.google.eclipse.protobuf.ui/src/com/google/eclipse/protobuf/ui/outline/ProtobufOutlineTreeProvider.java
index 412134b..6d1ed58 100644
--- a/com.google.eclipse.protobuf.ui/src/com/google/eclipse/protobuf/ui/outline/ProtobufOutlineTreeProvider.java
+++ b/com.google.eclipse.protobuf.ui/src/com/google/eclipse/protobuf/ui/outline/ProtobufOutlineTreeProvider.java
@@ -8,11 +8,15 @@
  */
 package com.google.eclipse.protobuf.ui.outline;
 
+import static com.google.eclipse.protobuf.protobuf.ProtobufPackage.Literals.*;
+
 import org.eclipse.emf.ecore.EObject;
 import org.eclipse.xtext.ui.editor.outline.IOutlineNode;
 import org.eclipse.xtext.ui.editor.outline.impl.DefaultOutlineTreeProvider;
+import org.eclipse.xtext.ui.editor.outline.impl.DocumentRootNode;
 
 import com.google.eclipse.protobuf.protobuf.*;
+import com.google.eclipse.protobuf.protobuf.Package;
 
 /**
  * Customization of the default outline structure.
@@ -29,6 +33,24 @@
     return true;
   }
 
+  protected void _createChildren(DocumentRootNode parentNode, Protobuf protobuf) {
+    Package aPackage = protobuf.getPackage();
+    if (aPackage != null) {
+      createNode(parentNode, aPackage);
+    }
+    if (!protobuf.getImports().isEmpty()) {
+      createEStructuralFeatureNode(parentNode, protobuf, PROTOBUF__IMPORTS,
+          labelProvider.getImage("imports"), "import declarations", false);
+    }
+    if (!protobuf.getOptions().isEmpty()) {
+      createEStructuralFeatureNode(parentNode, protobuf, PROTOBUF__OPTIONS,
+          labelProvider.getImage("options"), "option declarations", false);
+    }
+    for (ProtobufElement e : protobuf.getElements()) {
+      createNode(parentNode, e);
+    }
+  }
+
   @Override protected void createNode(IOutlineNode parent, EObject modelElement) {
     if (modelElement instanceof MessageReference) return;
     super.createNode(parent, modelElement);