Fixed outline view grouping of imports and options.
diff --git a/com.google.eclipse.protobuf.ui/src/com/google/eclipse/protobuf/ui/outline/OutlineViewModel.java b/com.google.eclipse.protobuf.ui/src/com/google/eclipse/protobuf/ui/outline/OutlineViewModel.java
new file mode 100644
index 0000000..7bfb540
--- /dev/null
+++ b/com.google.eclipse.protobuf.ui/src/com/google/eclipse/protobuf/ui/outline/OutlineViewModel.java
@@ -0,0 +1,65 @@
+/*
+ * Copyright (c) 2011 Google Inc.
+ *
+ * All rights reserved. This program and the accompanying materials are made available under the terms of the Eclipse
+ * Public License v1.0 which accompanies this distribution, and is available at
+ *
+ * http://www.eclipse.org/legal/epl-v10.html
+ */
+package com.google.eclipse.protobuf.ui.outline;
+
+import static com.google.inject.internal.Maps.newLinkedHashMap;
+import static java.util.Collections.unmodifiableList;
+
+import java.util.*;
+
+import org.eclipse.emf.ecore.EObject;
+
+import com.google.eclipse.protobuf.protobuf.*;
+import com.google.eclipse.protobuf.protobuf.Package;
+
+/**
+ * @author alruiz@google.com (Alex Ruiz)
+ */
+@SuppressWarnings("restriction")
+class OutlineViewModel {
+
+  private static final Class<?>[] GROUP_TYPES = { Package.class, Import.class, Option.class, ProtobufElement.class };
+
+  private final Map<Class<?>, List<EObject>> elements = newLinkedHashMap();
+
+  OutlineViewModel(Protobuf protobuf) {
+    initialize();
+    for (ProtobufElement e : protobuf.getElements()) {
+      for (Class<?> type : GROUP_TYPES) {
+        if (!type.isInstance(e)) continue;
+        elements.get(type).add(e);
+        break;
+      }
+    }
+  }
+
+  private void initialize() {
+    for (Class<?> type : GROUP_TYPES) elements.put(type, new ArrayList<EObject>());
+  }
+
+  List<EObject> packages() {
+    return elementsOfType(Package.class);
+  }
+
+  List<EObject> imports() {
+    return elementsOfType(Import.class);
+  }
+
+  List<EObject> options() {
+    return elementsOfType(Option.class);
+  }
+
+  List<EObject> remainingElements() {
+    return elementsOfType(ProtobufElement.class);
+  }
+
+  private List<EObject> elementsOfType(Class<?> type) {
+    return unmodifiableList(elements.get(type));
+  }
+}
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 7294426..8a6913f 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,6 +8,8 @@
  */
 package com.google.eclipse.protobuf.ui.outline;
 
+import static com.google.eclipse.protobuf.ui.outline.Messages.*;
+
 import java.util.*;
 
 import org.eclipse.emf.ecore.EObject;
@@ -40,23 +42,22 @@
   }
 
   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"), importDeclarations, false);
-//    }
-//    if (!protobuf.getOptions().isEmpty()) {
-//      createEStructuralFeatureNode(parentNode, protobuf, PROTOBUF__OPTIONS,
-//          labelProvider.getImage("options"), optionDeclarations, false);
-//    }
-    for (ProtobufElement e : protobuf.getElements()) {
+    OutlineViewModel model = new OutlineViewModel(protobuf);
+    for (EObject aPackage : model.packages()) createNode(parentNode, aPackage);
+    addGroup(parentNode, model.imports(), "imports", importDeclarations);
+    addGroup(parentNode, model.options(), "options", optionDeclarations);
+    for (EObject e : model.remainingElements()) {
       createNode(parentNode, e);
     }
   }
 
+  private void addGroup(DocumentRootNode parent, List<? extends EObject> group, String imageKey, String text) {
+    if (!group.isEmpty()) {
+      SimpleOutlineNode groupNode = new SimpleOutlineNode(parent, labelProvider.getImage(imageKey), text, false);
+      for (EObject o : group) createNode(groupNode, o);
+    }
+  }
+
   @Override protected void createNode(IOutlineNode parent, EObject modelElement) {
     if (isIgnored(modelElement)) return;
     super.createNode(parent, modelElement);
diff --git a/com.google.eclipse.protobuf.ui/src/com/google/eclipse/protobuf/ui/outline/SimpleOutlineNode.java b/com.google.eclipse.protobuf.ui/src/com/google/eclipse/protobuf/ui/outline/SimpleOutlineNode.java
new file mode 100644
index 0000000..f7787ff
--- /dev/null
+++ b/com.google.eclipse.protobuf.ui/src/com/google/eclipse/protobuf/ui/outline/SimpleOutlineNode.java
@@ -0,0 +1,23 @@
+/*
+ * Copyright (c) 2011 Google Inc.
+ *
+ * All rights reserved. This program and the accompanying materials are made available under the terms of the Eclipse
+ * Public License v1.0 which accompanies this distribution, and is available at
+ *
+ * http://www.eclipse.org/legal/epl-v10.html
+ */
+package com.google.eclipse.protobuf.ui.outline;
+
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.xtext.ui.editor.outline.IOutlineNode;
+import org.eclipse.xtext.ui.editor.outline.impl.AbstractOutlineNode;
+
+/**
+ * @author alruiz@google.com (Alex Ruiz)
+ */
+class SimpleOutlineNode extends AbstractOutlineNode {
+
+  SimpleOutlineNode(IOutlineNode parent, Image image, Object text, boolean isLeaf) {
+    super(parent, image, text, isLeaf);
+  }
+}