Fixed: [Issue 10] Allow "compiler" output folder name to more than one
hierarchy level
diff --git a/com.google.eclipse.protobuf.ui.test/src/com/google/eclipse/protobuf/ui/util/Paths_segmentsOf_Test.java b/com.google.eclipse.protobuf.ui.test/src/com/google/eclipse/protobuf/ui/util/Paths_segmentsOf_Test.java
new file mode 100644
index 0000000..8d5a546
--- /dev/null
+++ b/com.google.eclipse.protobuf.ui.test/src/com/google/eclipse/protobuf/ui/util/Paths_segmentsOf_Test.java
@@ -0,0 +1,38 @@
+/*
+ * 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.util;
+
+import static java.io.File.separator;
+import static org.hamcrest.core.IsEqual.equalTo;
+import static org.junit.Assert.assertThat;
+
+import org.junit.Test;
+
+/**
+ * Tests for <code>{@link Paths#segmentsOf(String)}</code>.
+ *
+ * @author alruiz@google.com (Alex Ruiz)
+ */
+public class Paths_segmentsOf_Test {
+
+  @Test(expected = NullPointerException.class)
+  public void should_throw_error_if_path_is_null() {
+    Paths.segmentsOf(null);
+  }
+  
+  @Test public void should_separate_segments_using_system_file_separator() {
+    String path = "folder1" + separator + "folder1_1" + separator + "folder1_1_1";
+    assertThat(Paths.segmentsOf(path), equalTo(new String[] { "folder1" , "folder1_1", "folder1_1_1" }));
+  }
+  
+  @Test public void should_separate_segments_for_path_ending_with_system_file_separator() {
+    String path = "folder1" + separator + "folder1_1" + separator;
+    assertThat(Paths.segmentsOf(path), equalTo(new String[] { "folder1" , "folder1_1" }));
+  }
+}
diff --git a/com.google.eclipse.protobuf.ui/src/com/google/eclipse/protobuf/ui/preferences/pages/compiler/EditCodeGenerationDialog.java b/com.google.eclipse.protobuf.ui/src/com/google/eclipse/protobuf/ui/preferences/pages/compiler/EditCodeGenerationDialog.java
index 2db3b2a..1271273 100644
--- a/com.google.eclipse.protobuf.ui/src/com/google/eclipse/protobuf/ui/preferences/pages/compiler/EditCodeGenerationDialog.java
+++ b/com.google.eclipse.protobuf.ui/src/com/google/eclipse/protobuf/ui/preferences/pages/compiler/EditCodeGenerationDialog.java
@@ -9,6 +9,7 @@
 package com.google.eclipse.protobuf.ui.preferences.pages.compiler;
 
 import static com.google.eclipse.protobuf.ui.preferences.pages.compiler.Messages.*;
+import static com.google.eclipse.protobuf.ui.util.Paths.segmentsOf;
 import static org.eclipse.core.resources.IResource.FOLDER;
 import static org.eclipse.jface.dialogs.IDialogConstants.OK_ID;
 import static org.eclipse.swt.layout.GridData.*;
@@ -109,8 +110,12 @@
 
   private String validateDirectoryName(String directoryName) {
     IWorkspace workspace = ResourcesPlugin.getWorkspace();
-    IStatus isValid = workspace.validateName(directoryName, FOLDER);
-    return (isValid.getCode() == OK) ? null : isValid.getMessage();
+    for (String segment : segmentsOf(directoryName)) {
+      IStatus isValid = workspace.validateName(segment, FOLDER);
+      if (isValid.getCode() == OK) continue;
+      return isValid.getMessage();
+    }
+    return null;
   }
 
   private void pageIsNowInvalid(String errorMessage) {
diff --git a/com.google.eclipse.protobuf.ui/src/com/google/eclipse/protobuf/ui/util/Paths.java b/com.google.eclipse.protobuf.ui/src/com/google/eclipse/protobuf/ui/util/Paths.java
new file mode 100644
index 0000000..edcada6
--- /dev/null
+++ b/com.google.eclipse.protobuf.ui/src/com/google/eclipse/protobuf/ui/util/Paths.java
@@ -0,0 +1,32 @@
+/*
+ * 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.util;
+
+import java.io.File;
+
+/**
+ * Utility methods related to paths.
+ *
+ * @author alruiz@google.com (Alex Ruiz)
+ */
+public final class Paths {
+
+  /**
+   * Returns the segments of the given path.
+   * @param path the given path.
+   * @return the segments of the given path.
+   * @throws NullPointerException if the given path is {@code null}.
+   */
+  public static String[] segmentsOf(String path) {
+    if (path == null) throw new NullPointerException("The given path should not be null");
+    return path.split(File.separator);
+  }
+  
+  private Paths() {}
+}