Finally fisished cleaning up preference page code.
diff --git a/com.google.eclipse.protobuf.ui.test/src/com/google/eclipse/protobuf/ui/preferences/pages/paths/DirectoryPath_parse_Test.java b/com.google.eclipse.protobuf.ui.test/src/com/google/eclipse/protobuf/ui/preferences/pages/paths/DirectoryPath_parse_Test.java
deleted file mode 100644
index 6ad7726..0000000
--- a/com.google.eclipse.protobuf.ui.test/src/com/google/eclipse/protobuf/ui/preferences/pages/paths/DirectoryPath_parse_Test.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * 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.preferences.pages.paths;
-
-import static org.hamcrest.core.IsEqual.equalTo;
-import static org.junit.Assert.*;
-
-import org.junit.Test;
-
-/**
- * Tests for <code>{@link DirectoryPath#parse(String)}</code>
- *
- * @author alruiz@google.com (Alex Ruiz)
- */
-public class DirectoryPath_parse_Test {
-
- @Test public void should_parse_workspace_path() {
- DirectoryPath path = DirectoryPath.parse("${workspace_loc:/test/src}");
- assertThat(path.value(), equalTo("/test/src"));
- assertTrue(path.isWorkspacePath());
- }
-
- @Test public void should_parse_file_system_path() {
- DirectoryPath path = DirectoryPath.parse("/test/src");
- assertThat(path.value(), equalTo("/test/src"));
- assertFalse(path.isWorkspacePath());
- }
-}
diff --git a/com.google.eclipse.protobuf.ui.test/src/com/google/eclipse/protobuf/ui/preferences/pages/paths/DirectoryPath_toString_Test.java b/com.google.eclipse.protobuf.ui.test/src/com/google/eclipse/protobuf/ui/preferences/pages/paths/DirectoryPath_toString_Test.java
deleted file mode 100644
index eb808f8..0000000
--- a/com.google.eclipse.protobuf.ui.test/src/com/google/eclipse/protobuf/ui/preferences/pages/paths/DirectoryPath_toString_Test.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * 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.preferences.pages.paths;
-
-import static org.hamcrest.core.IsEqual.equalTo;
-import static org.junit.Assert.assertThat;
-
-import org.junit.Test;
-
-/**
- * Tests for <code>{@link DirectoryPath#toString()}</code>
- *
- * @author alruiz@google.com (Alex Ruiz)
- */
-public class DirectoryPath_toString_Test {
-
- @Test public void should_specify_is_workspace_path() {
- DirectoryPath path = new DirectoryPath("/test/src", true);
- assertThat(path.toString(), equalTo("${workspace_loc:/test/src}"));
- }
-
- @Test public void should_specify_is_project_path() {
- DirectoryPath path = new DirectoryPath("/${project}/src", true);
- assertThat(path.toString(), equalTo("${workspace_loc:/${project}/src}"));
- }
-
- @Test public void should_return_plain_value_if_it_is_not_workspace_path() {
- DirectoryPath path = new DirectoryPath("/test/src", false);
- assertThat(path.toString(), equalTo("/test/src"));
- }
-}
diff --git a/com.google.eclipse.protobuf.ui.test/src/com/google/eclipse/protobuf/ui/preferences/pages/paths/ProjectVariable_useProjectName_Test.java b/com.google.eclipse.protobuf.ui.test/src/com/google/eclipse/protobuf/ui/preferences/pages/paths/ProjectVariable_useProjectName_Test.java
deleted file mode 100644
index 99606dd..0000000
--- a/com.google.eclipse.protobuf.ui.test/src/com/google/eclipse/protobuf/ui/preferences/pages/paths/ProjectVariable_useProjectName_Test.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * 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.preferences.pages.paths;
-
-import static org.hamcrest.core.IsEqual.equalTo;
-import static org.junit.Assert.assertThat;
-import static org.mockito.Mockito.*;
-
-import org.eclipse.core.resources.IProject;
-import org.junit.*;
-
-/**
- * Tests for <code>{@link ProjectVariable#useProjectName(String, IProject)}</code>.
- *
- * @author alruiz@google.com (Alex Ruiz)
- */
-public class ProjectVariable_useProjectName_Test {
-
- private IProject project;
-
- @Before public void setUp() {
- project = mock(IProject.class);
- }
-
- @Test public void should_use_project_name_if_path_contains_variable() {
- when(project.getName()).thenReturn("test");
- String newPath = ProjectVariable.useProjectName("/${project}/src/test", project);
- assertThat(newPath, equalTo("/test/src/test"));
- }
-
- @Test public void should_not_use_project_name_if_path_does_not_contain_variable() {
- when(project.getName()).thenReturn("test");
- String newPath = ProjectVariable.useProjectName("/main/src/test", project);
- assertThat(newPath, equalTo("/main/src/test"));
- }
-
- @Test public void should_not_use_project_name_if_path_already_contains_it() {
- when(project.getName()).thenReturn("test");
- String newPath = ProjectVariable.useProjectName("/test/src/test", project);
- assertThat(newPath, equalTo("/test/src/test"));
- }
-}
diff --git a/com.google.eclipse.protobuf.ui.test/src/com/google/eclipse/protobuf/ui/preferences/paths/core/DirectoryPath_parse_Test.java b/com.google.eclipse.protobuf.ui.test/src/com/google/eclipse/protobuf/ui/preferences/paths/core/DirectoryPath_parse_Test.java
new file mode 100644
index 0000000..68ce183
--- /dev/null
+++ b/com.google.eclipse.protobuf.ui.test/src/com/google/eclipse/protobuf/ui/preferences/paths/core/DirectoryPath_parse_Test.java
@@ -0,0 +1,49 @@
+/*
+ * 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.preferences.paths.core;
+
+import static org.hamcrest.core.IsEqual.equalTo;
+import static org.junit.Assert.*;
+import static org.mockito.Mockito.*;
+
+import org.eclipse.core.resources.IProject;
+import org.junit.*;
+
+/**
+ * Tests for <code>{@link DirectoryPath#parse(String, IProject)}</code>
+ *
+ * @author alruiz@google.com (Alex Ruiz)
+ */
+public class DirectoryPath_parse_Test {
+
+ private IProject project;
+
+ @Before public void setUp() {
+ project = mock(IProject.class);
+ }
+
+ @Test public void should_parse_workspace_path() {
+ when(project.getName()).thenReturn("test");
+ DirectoryPath path = DirectoryPath.parse("${workspace_loc:/${project}/src}", project);
+ assertThat(path.value(), equalTo("/test/src"));
+ assertTrue(path.isWorkspacePath());
+ }
+
+ @Test public void should_parse_workspace_path_with_null_IProject() {
+ DirectoryPath path = DirectoryPath.parse("${workspace_loc:/test/src}", null);
+ assertThat(path.value(), equalTo("/test/src"));
+ assertTrue(path.isWorkspacePath());
+ }
+
+ @Test public void should_parse_file_system_path() {
+ DirectoryPath path = DirectoryPath.parse("/test/src", project);
+ assertThat(path.value(), equalTo("/test/src"));
+ assertFalse(path.isWorkspacePath());
+ }
+}
diff --git a/com.google.eclipse.protobuf.ui.test/src/com/google/eclipse/protobuf/ui/preferences/pages/paths/ProjectVariable_useProjectVariable_Test.java b/com.google.eclipse.protobuf.ui.test/src/com/google/eclipse/protobuf/ui/preferences/paths/core/ProjectVariable_replaceProjectNameWithProjectVariable_Test.java
similarity index 62%
rename from com.google.eclipse.protobuf.ui.test/src/com/google/eclipse/protobuf/ui/preferences/pages/paths/ProjectVariable_useProjectVariable_Test.java
rename to com.google.eclipse.protobuf.ui.test/src/com/google/eclipse/protobuf/ui/preferences/paths/core/ProjectVariable_replaceProjectNameWithProjectVariable_Test.java
index df5ce9e..88527f5 100644
--- a/com.google.eclipse.protobuf.ui.test/src/com/google/eclipse/protobuf/ui/preferences/pages/paths/ProjectVariable_useProjectVariable_Test.java
+++ b/com.google.eclipse.protobuf.ui.test/src/com/google/eclipse/protobuf/ui/preferences/paths/core/ProjectVariable_replaceProjectNameWithProjectVariable_Test.java
@@ -6,7 +6,7 @@
*
* http://www.eclipse.org/legal/epl-v10.html
*/
-package com.google.eclipse.protobuf.ui.preferences.pages.paths;
+package com.google.eclipse.protobuf.ui.preferences.paths.core;
import static org.hamcrest.core.IsEqual.equalTo;
import static org.junit.Assert.assertThat;
@@ -17,11 +17,11 @@
import org.junit.*;
/**
- * Tests for <code>{@link ProjectVariable#useProjectVariable(IPath, IProject)}</code>.
+ * Tests for <code>{@link ProjectVariable#replaceProjectNameWithProjectVariable(IPath, IProject)}</code>.
*
* @author alruiz@google.com (Alex Ruiz)
*/
-public class ProjectVariable_useProjectVariable_Test {
+public class ProjectVariable_replaceProjectNameWithProjectVariable_Test {
private IProject project;
@@ -32,21 +32,21 @@
@Test public void should_use_variable_if_path_contains_project_name() {
IPath path = new Path("/test/src/test");
when(project.getName()).thenReturn("test");
- IPath newPath = ProjectVariable.useProjectVariable(path, project);
- assertThat(newPath.toString(), equalTo("/${project}/src/test"));
+ IPath newPath = ProjectVariable.replaceProjectNameWithProjectVariable(path, project);
+ assertThat(newPath.toOSString(), equalTo("/${project}/src/test"));
}
@Test public void should_not_use_variable_if_path_does_not_contain_project_name() {
IPath path = new Path("/main/src/test");
when(project.getName()).thenReturn("test");
- IPath newPath = ProjectVariable.useProjectVariable(path, project);
- assertThat(newPath.toString(), equalTo("/main/src/test"));
+ IPath newPath = ProjectVariable.replaceProjectNameWithProjectVariable(path, project);
+ assertThat(newPath.toOSString(), equalTo("/main/src/test"));
}
@Test public void should_not_use_variable_if_path_already_contains_it() {
IPath path = new Path("/${project}/src/test");
when(project.getName()).thenReturn("test");
- IPath newPath = ProjectVariable.useProjectVariable(path, project);
- assertThat(newPath.toString(), equalTo("/${project}/src/test"));
+ IPath newPath = ProjectVariable.replaceProjectNameWithProjectVariable(path, project);
+ assertThat(newPath.toOSString(), equalTo("/${project}/src/test"));
}
}
diff --git a/com.google.eclipse.protobuf.ui.test/src/com/google/eclipse/protobuf/ui/preferences/paths/core/ProjectVariable_replaceProjectVariableWithProjectName_Test.java b/com.google.eclipse.protobuf.ui.test/src/com/google/eclipse/protobuf/ui/preferences/paths/core/ProjectVariable_replaceProjectVariableWithProjectName_Test.java
new file mode 100644
index 0000000..145d576
--- /dev/null
+++ b/com.google.eclipse.protobuf.ui.test/src/com/google/eclipse/protobuf/ui/preferences/paths/core/ProjectVariable_replaceProjectVariableWithProjectName_Test.java
@@ -0,0 +1,52 @@
+/*
+ * 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.preferences.paths.core;
+
+import static org.hamcrest.core.IsEqual.equalTo;
+import static org.junit.Assert.assertThat;
+import static org.mockito.Mockito.*;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.*;
+import org.junit.*;
+
+/**
+ * Tests for <code>{@link ProjectVariable#replaceProjectVariableWithProjectName(IPath, IProject)}</code>.
+ *
+ * @author alruiz@google.com (Alex Ruiz)
+ */
+public class ProjectVariable_replaceProjectVariableWithProjectName_Test {
+
+ private IProject project;
+
+ @Before public void setUp() {
+ project = mock(IProject.class);
+ }
+
+ @Test public void should_use_project_name_if_path_contains_variable() {
+ when(project.getName()).thenReturn("test");
+ IPath path = new Path("/${project}/src/test");
+ IPath newPath = ProjectVariable.replaceProjectVariableWithProjectName(path, project);
+ assertThat(newPath.toOSString(), equalTo("/test/src/test"));
+ }
+
+ @Test public void should_not_use_project_name_if_path_does_not_contain_variable() {
+ when(project.getName()).thenReturn("test");
+ IPath path = new Path("/main/src/test");
+ IPath newPath = ProjectVariable.replaceProjectVariableWithProjectName(path, project);
+ assertThat(newPath.toOSString(), equalTo("/main/src/test"));
+ }
+
+ @Test public void should_not_use_project_name_if_path_already_contains_it() {
+ when(project.getName()).thenReturn("test");
+ IPath path = new Path("/test/src/test");
+ IPath newPath = ProjectVariable.replaceProjectVariableWithProjectName(path, project);
+ assertThat(newPath.toOSString(), equalTo("/test/src/test"));
+ }
+}
diff --git a/com.google.eclipse.protobuf.ui.test/src/com/google/eclipse/protobuf/ui/scoping/SingleDirectoryFileResolver_resolveUri_Test.java b/com.google.eclipse.protobuf.ui.test/src/com/google/eclipse/protobuf/ui/scoping/SingleDirectoryFileResolver_resolveUri_Test.java
index 3de99ee..f4e29b3 100644
--- a/com.google.eclipse.protobuf.ui.test/src/com/google/eclipse/protobuf/ui/scoping/SingleDirectoryFileResolver_resolveUri_Test.java
+++ b/com.google.eclipse.protobuf.ui.test/src/com/google/eclipse/protobuf/ui/scoping/SingleDirectoryFileResolver_resolveUri_Test.java
@@ -17,7 +17,7 @@
import org.eclipse.emf.common.util.URI;
import org.junit.*;
-import com.google.eclipse.protobuf.ui.preferences.pages.paths.PathsPreferences;
+import com.google.eclipse.protobuf.ui.preferences.paths.core.PathsPreferences;
import com.google.eclipse.protobuf.ui.util.Resources;
/**
diff --git a/com.google.eclipse.protobuf.ui.test/src/com/google/eclipse/protobuf/ui/util/CommaSeparatedValues_splitCsv_Test.java b/com.google.eclipse.protobuf.ui.test/src/com/google/eclipse/protobuf/ui/util/CommaSeparatedValues_splitCsv_Test.java
new file mode 100644
index 0000000..b903177
--- /dev/null
+++ b/com.google.eclipse.protobuf.ui.test/src/com/google/eclipse/protobuf/ui/util/CommaSeparatedValues_splitCsv_Test.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 static org.hamcrest.core.IsEqual.equalTo;
+import static org.junit.Assert.assertThat;
+
+import org.junit.Test;
+
+/**
+ * Tests for <code>{@link CommaSeparatedValues#splitCsv(String)}</code>.
+ *
+ * @author alruiz@google.com (Alex Ruiz)
+ */
+public class CommaSeparatedValues_splitCsv_Test {
+
+ @Test public void should_split_CSV() {
+ String[] values = CommaSeparatedValues.splitCsv("Yoda, Leia, Luke");
+ assertThat(values, equalTo(new String[] { "Yoda", "Leia", "Luke" }));
+ }
+
+ @Test public void should_return_same_String_if_it_is_not_CSV() {
+ String[] values = CommaSeparatedValues.splitCsv("Yoda");
+ assertThat(values, equalTo(new String[] { "Yoda" }));
+ }
+}
diff --git a/com.google.eclipse.protobuf.ui/plugin.xml b/com.google.eclipse.protobuf.ui/plugin.xml
index ffe8025..794e98a 100644
--- a/com.google.eclipse.protobuf.ui/plugin.xml
+++ b/com.google.eclipse.protobuf.ui/plugin.xml
@@ -216,7 +216,7 @@
</extension>
<extension point="org.eclipse.ui.propertyPages">
<page
- class="com.google.eclipse.protobuf.ui.ProtobufExecutableExtensionFactory:com.google.eclipse.protobuf.ui.preferences.pages.general.GeneralPreferencePage"
+ class="com.google.eclipse.protobuf.ui.ProtobufExecutableExtensionFactory:com.google.eclipse.protobuf.ui.preferences.general.page.GeneralPreferencePage"
id="com.google.eclipse.protobuf.Protobuf"
name="%page.name"
selectionFilter="single">
@@ -237,7 +237,7 @@
</page>
<page
category="com.google.eclipse.protobuf.Protobuf"
- class="com.google.eclipse.protobuf.ui.ProtobufExecutableExtensionFactory:com.google.eclipse.protobuf.ui.preferences.pages.paths.PathsPreferencePage"
+ class="com.google.eclipse.protobuf.ui.ProtobufExecutableExtensionFactory:com.google.eclipse.protobuf.ui.preferences.paths.page.PathsPreferencePage"
id="com.google.eclipse.protobuf.ui.properties.paths.PropertyPage"
name="%page.name.3"
selectionFilter="single">
diff --git a/com.google.eclipse.protobuf.ui/src/com/google/eclipse/protobuf/ui/ProtobufUiModule.java b/com.google.eclipse.protobuf.ui/src/com/google/eclipse/protobuf/ui/ProtobufUiModule.java
index 7de4f38..9b8d95f 100644
--- a/com.google.eclipse.protobuf.ui/src/com/google/eclipse/protobuf/ui/ProtobufUiModule.java
+++ b/com.google.eclipse.protobuf.ui/src/com/google/eclipse/protobuf/ui/ProtobufUiModule.java
@@ -41,7 +41,7 @@
import com.google.eclipse.protobuf.ui.preferences.editor.numerictag.core.NumericTagPreferenceStoreInitializer;
import com.google.eclipse.protobuf.ui.preferences.editor.save.core.SaveActionsPreferenceStoreInitializer;
import com.google.eclipse.protobuf.ui.preferences.general.core.GeneralPreferenceStoreInitializer;
-import com.google.eclipse.protobuf.ui.preferences.pages.paths.PathsPreferenceStoreInitializer;
+import com.google.eclipse.protobuf.ui.preferences.paths.core.PathsPreferenceStoreInitializer;
import com.google.eclipse.protobuf.ui.quickfix.ProtobufQuickAssistProcessor;
import com.google.eclipse.protobuf.ui.scoping.FileUriResolver;
import com.google.eclipse.protobuf.ui.validation.*;
diff --git a/com.google.eclipse.protobuf.ui/src/com/google/eclipse/protobuf/ui/builder/protoc/ProtobufBuildParticipant.java b/com.google.eclipse.protobuf.ui/src/com/google/eclipse/protobuf/ui/builder/protoc/ProtobufBuildParticipant.java
index 0c8e355..5b4a7c2 100644
--- a/com.google.eclipse.protobuf.ui/src/com/google/eclipse/protobuf/ui/builder/protoc/ProtobufBuildParticipant.java
+++ b/com.google.eclipse.protobuf.ui/src/com/google/eclipse/protobuf/ui/builder/protoc/ProtobufBuildParticipant.java
@@ -10,7 +10,7 @@
import static com.google.eclipse.protobuf.ui.exception.CoreExceptions.error;
import static com.google.eclipse.protobuf.ui.preferences.compiler.core.CompilerPreferences.compilerPreferences;
-import static com.google.eclipse.protobuf.ui.preferences.pages.paths.PathResolutionType.MULTIPLE_DIRECTORIES;
+import static com.google.eclipse.protobuf.ui.util.CommaSeparatedValues.splitCsv;
import static com.google.eclipse.protobuf.util.Closeables.closeQuietly;
import static java.util.Collections.*;
import static org.eclipse.core.resources.IResource.DEPTH_INFINITE;
@@ -27,7 +27,7 @@
import org.eclipse.xtext.ui.editor.preferences.IPreferenceStoreAccess;
import com.google.eclipse.protobuf.ui.preferences.compiler.core.CompilerPreferences;
-import com.google.eclipse.protobuf.ui.preferences.pages.paths.*;
+import com.google.eclipse.protobuf.ui.preferences.paths.core.*;
import com.google.inject.Inject;
/**
@@ -37,11 +37,10 @@
*/
public class ProtobufBuildParticipant implements IXtextBuilderParticipant {
- @Inject private IPreferenceStoreAccess storeAccess;
- @Inject private PathsPreferencesFactory pathsPreferencesFactory;
@Inject private ProtocCommandFactory commandFactory;
@Inject private ProtocOutputParser outputParser;
@Inject private ProtoDescriptorPathFinder protoDescriptorPathFinder;
+ @Inject private IPreferenceStoreAccess storeAccess;
@Override public void build(IBuildContext context, IProgressMonitor monitor) throws CoreException {
IProject project = context.getBuiltProject();
@@ -78,11 +77,12 @@
private List<String> importRoots(IProject project) {
List<String> paths = new ArrayList<String>();
- PathsPreferences preferences = pathsPreferencesFactory.preferences(project);
- if (MULTIPLE_DIRECTORIES.equals(preferences.pathResolutionType())) {
- List<DirectoryPath> directoryPaths = preferences.importRoots();
- for (DirectoryPath path : directoryPaths) {
- String location = path.location(project);
+ PathsPreferences preferences = new PathsPreferences(storeAccess, project);
+ if (preferences.filesInMultipleDirectories().getValue()) {
+ String directoryPaths = preferences.directoryPaths().getValue();
+ for (String importRoot : splitCsv(directoryPaths)) {
+ DirectoryPath path = DirectoryPath.parse(importRoot, project);
+ String location = path.absolutePathInFileSystem();
if (location != null) {
paths.add(location);
}
diff --git a/com.google.eclipse.protobuf.ui/src/com/google/eclipse/protobuf/ui/preferences/compiler/page/CompilerPreferencePage.java b/com.google.eclipse.protobuf.ui/src/com/google/eclipse/protobuf/ui/preferences/compiler/page/CompilerPreferencePage.java
index c543462..ce934d2 100644
--- a/com.google.eclipse.protobuf.ui/src/com/google/eclipse/protobuf/ui/preferences/compiler/page/CompilerPreferencePage.java
+++ b/com.google.eclipse.protobuf.ui/src/com/google/eclipse/protobuf/ui/preferences/compiler/page/CompilerPreferencePage.java
@@ -359,6 +359,10 @@
}
private void checkState() {
+ if (isPropertyPage() && !areProjectSettingsActive()) {
+ pageIsNowValid();
+ return;
+ }
if (!atLeastOneTargetLanguageIsSelected()) {
pageIsNowInvalid(errorNoLanguageSelected);
return;
diff --git a/com.google.eclipse.protobuf.ui/src/com/google/eclipse/protobuf/ui/preferences/pages/PreferenceAndPropertyPage.java b/com.google.eclipse.protobuf.ui/src/com/google/eclipse/protobuf/ui/preferences/pages/PreferenceAndPropertyPage.java
index 9705c99..27e7736 100644
--- a/com.google.eclipse.protobuf.ui/src/com/google/eclipse/protobuf/ui/preferences/pages/PreferenceAndPropertyPage.java
+++ b/com.google.eclipse.protobuf.ui/src/com/google/eclipse/protobuf/ui/preferences/pages/PreferenceAndPropertyPage.java
@@ -36,9 +36,7 @@
*/
public abstract class PreferenceAndPropertyPage extends PreferencePage implements IWorkbenchPreferencePage,
IWorkbenchPropertyPage {
-
private Button btnEnableProjectSettings;
-
private Link lnkEnableWorkspaceSettings;
private IProject project;
diff --git a/com.google.eclipse.protobuf.ui/src/com/google/eclipse/protobuf/ui/preferences/pages/binding/Binding.java b/com.google.eclipse.protobuf.ui/src/com/google/eclipse/protobuf/ui/preferences/pages/binding/Binding.java
index d9c662c..ed7e68a 100644
--- a/com.google.eclipse.protobuf.ui/src/com/google/eclipse/protobuf/ui/preferences/pages/binding/Binding.java
+++ b/com.google.eclipse.protobuf.ui/src/com/google/eclipse/protobuf/ui/preferences/pages/binding/Binding.java
@@ -18,17 +18,17 @@
public interface Binding {
/**
- * Reads a preference value and applies it to this binding's target object.
+ * Reads a preference value and applies it to the target object.
*/
void applyPreferenceValueToTarget();
/**
- * Reads a default value preference and applies it to the this binding's target object.
+ * Reads a default value preference and applies it to the the target object.
*/
void applyDefaultPreferenceValueToTarget();
/**
- * Applies the value of this binding's target object to a preference.
+ * Saves the value of the target object to a preference.
*/
void savePreferenceValue();
}
diff --git a/com.google.eclipse.protobuf.ui/src/com/google/eclipse/protobuf/ui/preferences/pages/paths/DirectoryPath.java b/com.google.eclipse.protobuf.ui/src/com/google/eclipse/protobuf/ui/preferences/pages/paths/DirectoryPath.java
deleted file mode 100644
index 9da8ec1..0000000
--- a/com.google.eclipse.protobuf.ui/src/com/google/eclipse/protobuf/ui/preferences/pages/paths/DirectoryPath.java
+++ /dev/null
@@ -1,103 +0,0 @@
-/*
- * 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.preferences.pages.paths;
-
-import static com.google.eclipse.protobuf.ui.preferences.pages.paths.ProjectVariable.useProjectName;
-import static java.util.regex.Pattern.compile;
-
-import java.util.regex.*;
-
-import org.eclipse.core.filesystem.*;
-import org.eclipse.core.resources.*;
-import org.eclipse.core.runtime.Path;
-
-/**
- * Represents the path of a directory.
- *
- * @author alruiz@google.com (Alex Ruiz)
- */
-public class DirectoryPath {
-
- private static final Pattern WORKSPACE_PATH_PATTERN = compile("\\$\\{workspace_loc:(.*)\\}");
-
- private final String value;
- private final boolean isWorkspacePath;
-
- static DirectoryPath parse(String path) {
- return parse(path, null);
- }
-
- static DirectoryPath parse(String path, IProject project) {
- Matcher matcher = WORKSPACE_PATH_PATTERN.matcher(path);
- if (matcher.matches()) {
- String actualPath = matcher.group(1);
- if (project != null) {
- actualPath = useProjectName(actualPath, project);
- }
- return new DirectoryPath(actualPath, true);
- }
- return new DirectoryPath(path, false);
- }
-
- DirectoryPath(String path, boolean isWorkspacePath) {
- this.value = path;
- this.isWorkspacePath = isWorkspacePath;
- }
-
- /** {@inheritDoc} */
- @Override public String toString() {
- if (!isWorkspacePath) {
- return value;
- }
- return "${workspace_loc:" + value + "}";
- }
-
- /**
- * Returns the textual value of this path.
- * @return the textual value of this path.
- */
- public String value() {
- return value;
- }
-
- /**
- * Indicates whether this path belongs to a workspace resource.
- * @return {@code true} if this path belongs to a workspace resource, {@code false} otherwise.
- */
- public boolean isWorkspacePath() {
- return isWorkspacePath;
- }
-
- /**
- * Returns the absolute path in the local file system, or {@code null} if no path can be determined.
- * @param project used if this path belongs to a workspace resource.
- * @return the absolute path in the local file system, or {@code null} if no path can be determined.
- */
- public String location(IProject project) {
- if (isWorkspacePath()) {
- return locationOfWorkspaceDirectory(project);
- }
- return locationOfFileSystemDirectory();
- }
-
- private String locationOfWorkspaceDirectory(IProject project) {
- IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
- IFolder folder = root.getFolder(new Path(value()));
- return folder.getLocation().toOSString();
- }
-
- private String locationOfFileSystemDirectory() {
- IFileSystem fileSystem = EFS.getLocalFileSystem();
- IFileInfo fileInfo = fileSystem.getStore(new Path(value())).fetchInfo();
- if (!fileInfo.isDirectory()) {
- return null;
- }
- return value();
- }
-}
diff --git a/com.google.eclipse.protobuf.ui/src/com/google/eclipse/protobuf/ui/preferences/pages/paths/PathResolutionType.java b/com.google.eclipse.protobuf.ui/src/com/google/eclipse/protobuf/ui/preferences/pages/paths/PathResolutionType.java
deleted file mode 100644
index 29fbfa6..0000000
--- a/com.google.eclipse.protobuf.ui/src/com/google/eclipse/protobuf/ui/preferences/pages/paths/PathResolutionType.java
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- * 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.preferences.pages.paths;
-
-/**
- * Types of file resolution.
- *
- * @author alruiz@google.com (Alex Ruiz)
- */
-public enum PathResolutionType {
-
- SINGLE_DIRECTORY, MULTIPLE_DIRECTORIES;
-
-}
diff --git a/com.google.eclipse.protobuf.ui/src/com/google/eclipse/protobuf/ui/preferences/pages/paths/PathsPreferences.java b/com.google.eclipse.protobuf.ui/src/com/google/eclipse/protobuf/ui/preferences/pages/paths/PathsPreferences.java
deleted file mode 100644
index bb2b556..0000000
--- a/com.google.eclipse.protobuf.ui/src/com/google/eclipse/protobuf/ui/preferences/pages/paths/PathsPreferences.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * 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.preferences.pages.paths;
-
-import static com.google.eclipse.protobuf.ui.preferences.pages.paths.PathResolutionType.*;
-import static java.util.Collections.*;
-
-import java.util.*;
-
-import org.eclipse.core.resources.IProject;
-import org.eclipse.jface.preference.IPreferenceStore;
-
-/**
- * Paths preferences, retrieved from an <code>{@link IPreferenceStore}</code>.
- *
- * @author alruiz@google.com (Alex Ruiz)
- */
-public class PathsPreferences {
-
- private final PathResolutionType pathResolutionType;
- private final List<DirectoryPath> importRoots;
-
- private static final String CSV_PATTERN = "[\\s]*,[\\s]*";
-
- PathsPreferences(RawPreferences preferences, IProject project) {
- boolean filesInOneDirectoryOnly = preferences.filesInOneDirectoryOnly().getValue();
- pathResolutionType = filesInOneDirectoryOnly ? SINGLE_DIRECTORY : MULTIPLE_DIRECTORIES;
- importRoots = importRoots(preferences, project);
- }
-
- private List<DirectoryPath> importRoots(RawPreferences preferences, IProject project) {
- if (pathResolutionType.equals(SINGLE_DIRECTORY)) {
- return emptyList();
- }
- List<DirectoryPath> roots = new ArrayList<DirectoryPath>();
- for (String root : preferences.directoryPaths().getValue().split(CSV_PATTERN)) {
- roots.add(DirectoryPath.parse(root, project));
- }
- return unmodifiableList(roots);
- }
-
- public PathResolutionType pathResolutionType() {
- return pathResolutionType;
- }
-
- public List<DirectoryPath> importRoots() {
- return importRoots;
- }
-}
diff --git a/com.google.eclipse.protobuf.ui/src/com/google/eclipse/protobuf/ui/preferences/pages/paths/PathsPreferencesFactory.java b/com.google.eclipse.protobuf.ui/src/com/google/eclipse/protobuf/ui/preferences/pages/paths/PathsPreferencesFactory.java
deleted file mode 100644
index f5f3009..0000000
--- a/com.google.eclipse.protobuf.ui/src/com/google/eclipse/protobuf/ui/preferences/pages/paths/PathsPreferencesFactory.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- * 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.preferences.pages.paths;
-
-import org.eclipse.core.resources.IProject;
-import org.eclipse.jface.preference.IPreferenceStore;
-import org.eclipse.xtext.ui.editor.preferences.IPreferenceStoreAccess;
-
-import com.google.inject.Inject;
-
-/**
- * Factory of <code>{@link PathsPreferences}</code>.
- *
- * @author alruiz@google.com (Alex Ruiz)
- */
-public class PathsPreferencesFactory {
-
- @Inject private IPreferenceStoreAccess storeAccess;
-
- public PathsPreferences preferences(IProject project) {
- IPreferenceStore store = storeAccess.getWritablePreferenceStore(project);
- return new PathsPreferences(new RawPreferences(store), project);
- }
-}
diff --git a/com.google.eclipse.protobuf.ui/src/com/google/eclipse/protobuf/ui/preferences/pages/paths/RawPreferences.java b/com.google.eclipse.protobuf.ui/src/com/google/eclipse/protobuf/ui/preferences/pages/paths/RawPreferences.java
deleted file mode 100644
index c1f77f7..0000000
--- a/com.google.eclipse.protobuf.ui/src/com/google/eclipse/protobuf/ui/preferences/pages/paths/RawPreferences.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * 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.preferences.pages.paths;
-
-import org.eclipse.jface.preference.IPreferenceStore;
-
-import com.google.eclipse.protobuf.ui.preferences.*;
-
-/**
- * @author alruiz@google.com (Alex Ruiz)
- */
-class RawPreferences {
-
- private final BooleanPreference filesInOneDirectoryOnly;
- private final BooleanPreference filesInMultipleDirectories;
- private final StringPreference directoryPaths;
-
- RawPreferences(IPreferenceStore store) {
- filesInOneDirectoryOnly = new BooleanPreference("paths.filesInOneDirectoryOnly", store);
- filesInMultipleDirectories = new BooleanPreference("paths.filesInMultipleDirectories", store);
- directoryPaths = new StringPreference("paths.directoryPaths", store);
- }
-
- BooleanPreference filesInOneDirectoryOnly() {
- return filesInOneDirectoryOnly;
- }
-
- BooleanPreference filesInMultipleDirectories() {
- return filesInMultipleDirectories;
- }
-
- StringPreference directoryPaths() {
- return directoryPaths;
- }
-}
diff --git a/com.google.eclipse.protobuf.ui/src/com/google/eclipse/protobuf/ui/preferences/paths/core/DirectoryPath.java b/com.google.eclipse.protobuf.ui/src/com/google/eclipse/protobuf/ui/preferences/paths/core/DirectoryPath.java
new file mode 100644
index 0000000..a49a675
--- /dev/null
+++ b/com.google.eclipse.protobuf.ui/src/com/google/eclipse/protobuf/ui/preferences/paths/core/DirectoryPath.java
@@ -0,0 +1,99 @@
+/*
+ * 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.preferences.paths.core;
+
+import static com.google.eclipse.protobuf.ui.preferences.paths.core.ProjectVariable.replaceProjectVariableWithProjectName;
+
+import java.util.regex.*;
+
+import org.eclipse.core.filesystem.*;
+import org.eclipse.core.resources.*;
+import org.eclipse.core.runtime.*;
+
+/**
+ * Represents the path of a directory.
+ *
+ * @author alruiz@google.com (Alex Ruiz)
+ */
+public class DirectoryPath {
+ private static final Pattern WORKSPACE_PATH_PATTERN = Pattern.compile("\\$\\{workspace_loc:(.*)\\}");
+
+ private final String value;
+ private final boolean isWorkspacePath;
+
+ /**
+ * Creates a new <code>{@link DirectoryPath}</code>.
+ * @param path the path to parse. If the path belongs to a file in the workspace it should match the pattern
+ * "\$\{workspace_loc:(.*)\}".
+ * @param project the current project.
+ * @return the created {@code DirectoryPath}.
+ */
+ public static DirectoryPath parse(String path, IProject project) {
+ Matcher matcher = WORKSPACE_PATH_PATTERN.matcher(path);
+ String actualPath = path;
+ boolean isWorkspacePath = false;
+ if (matcher.matches()) {
+ actualPath = matcher.group(1);
+ isWorkspacePath = true;
+ if (project != null) {
+ IPath newPath = replaceProjectVariableWithProjectName(new Path(actualPath), project);
+ actualPath = newPath.toOSString();
+ }
+ }
+ return new DirectoryPath(actualPath, isWorkspacePath);
+ }
+
+ private DirectoryPath(String path, boolean isWorkspacePath) {
+ this.value = path;
+ this.isWorkspacePath = isWorkspacePath;
+ }
+
+ /**
+ * Returns the textual value of this path.
+ * @return the textual value of this path.
+ */
+ public String value() {
+ return value;
+ }
+
+ /**
+ * Indicates whether this path belongs to a workspace resource.
+ * @return {@code true} if this path belongs to a workspace resource, {@code false} otherwise.
+ */
+ public boolean isWorkspacePath() {
+ return isWorkspacePath;
+ }
+
+ /**
+ * Returns the absolute path in the local file system, or {@code null} if no path can be determined.
+ * @return the absolute path in the local file system, or {@code null} if no path can be determined.
+ */
+ public String absolutePathInFileSystem() {
+ Path path = new Path(value);
+ if (isWorkspacePath()) {
+ return locationOfWorkspaceDirectory(path);
+ }
+ return locationOfFileSystemDirectory(path);
+ }
+
+ private String locationOfWorkspaceDirectory(Path path) {
+ IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
+ IFolder directory = root.getFolder(path);
+ return directory.getLocation().toOSString();
+ }
+
+ private String locationOfFileSystemDirectory(Path path) {
+ IFileSystem fileSystem = EFS.getLocalFileSystem();
+ IFileInfo fileInfo = fileSystem.getStore(path).fetchInfo();
+ if (!fileInfo.isDirectory()) {
+ return null;
+ }
+ return value;
+ }
+}
diff --git a/com.google.eclipse.protobuf.ui/src/com/google/eclipse/protobuf/ui/preferences/pages/paths/PathsPreferenceStoreInitializer.java b/com.google.eclipse.protobuf.ui/src/com/google/eclipse/protobuf/ui/preferences/paths/core/PathsPreferenceStoreInitializer.java
similarity index 87%
rename from com.google.eclipse.protobuf.ui/src/com/google/eclipse/protobuf/ui/preferences/pages/paths/PathsPreferenceStoreInitializer.java
rename to com.google.eclipse.protobuf.ui/src/com/google/eclipse/protobuf/ui/preferences/paths/core/PathsPreferenceStoreInitializer.java
index 3ffa066..8474eda 100644
--- a/com.google.eclipse.protobuf.ui/src/com/google/eclipse/protobuf/ui/preferences/pages/paths/PathsPreferenceStoreInitializer.java
+++ b/com.google.eclipse.protobuf.ui/src/com/google/eclipse/protobuf/ui/preferences/paths/core/PathsPreferenceStoreInitializer.java
@@ -6,7 +6,7 @@
*
* http://www.eclipse.org/legal/epl-v10.html
*/
-package com.google.eclipse.protobuf.ui.preferences.pages.paths;
+package com.google.eclipse.protobuf.ui.preferences.paths.core;
import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.xtext.ui.editor.preferences.*;
@@ -21,7 +21,7 @@
/** {@inheritDoc} */
@Override public void initialize(IPreferenceStoreAccess access) {
IPreferenceStore store = access.getWritablePreferenceStore();
- RawPreferences preferences = new RawPreferences(store);
+ PathsPreferences preferences = new PathsPreferences(store);
preferences.filesInOneDirectoryOnly().setDefaultValue(true);
preferences.filesInMultipleDirectories().setDefaultValue(false);
preferences.directoryPaths().setDefaultValue("");
diff --git a/com.google.eclipse.protobuf.ui/src/com/google/eclipse/protobuf/ui/preferences/paths/core/PathsPreferences.java b/com.google.eclipse.protobuf.ui/src/com/google/eclipse/protobuf/ui/preferences/paths/core/PathsPreferences.java
index 1e4fa56..e197f18 100644
--- a/com.google.eclipse.protobuf.ui/src/com/google/eclipse/protobuf/ui/preferences/paths/core/PathsPreferences.java
+++ b/com.google.eclipse.protobuf.ui/src/com/google/eclipse/protobuf/ui/preferences/paths/core/PathsPreferences.java
@@ -8,7 +8,9 @@
*/
package com.google.eclipse.protobuf.ui.preferences.paths.core;
+import org.eclipse.core.resources.IProject;
import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.xtext.ui.editor.preferences.IPreferenceStoreAccess;
import com.google.eclipse.protobuf.ui.preferences.*;
import com.google.eclipse.protobuf.ui.preferences.editor.save.core.SaveActionsPreferences;
@@ -19,16 +21,35 @@
* @author alruiz@google.com (Alex Ruiz)
*/
public class PathsPreferences {
-
private final BooleanPreference filesInOneDirectoryOnly;
private final BooleanPreference filesInMultipleDirectories;
private final StringPreference directoryPaths;
+ private final IProject project;
+
+ /**
+ * Creates a new <code>{@link PathsPreferences}</code>.
+ * @param storeAccess simplified access to Eclipse's preferences.
+ * @param project the current project.
+ */
+ public PathsPreferences(IPreferenceStoreAccess storeAccess, IProject project) {
+ this(storeAccess.getWritablePreferenceStore(project), project);
+ }
/**
* Creates a new <code>{@link SaveActionsPreferences}</code>.
* @param store a table mapping named preferences to values.
*/
public PathsPreferences(IPreferenceStore store) {
+ this(store, null);
+ }
+
+ /**
+ * Creates a new <code>{@link SaveActionsPreferences}</code>.
+ * @param store a table mapping named preferences to values.
+ * @param project the current project.
+ */
+ public PathsPreferences(IPreferenceStore store, IProject project) {
+ this.project = project;
filesInOneDirectoryOnly = new BooleanPreference("paths.filesInOneDirectoryOnly", store);
filesInMultipleDirectories = new BooleanPreference("paths.filesInMultipleDirectories", store);
directoryPaths = new StringPreference("paths.directoryPaths", store);
@@ -59,4 +80,12 @@
public StringPreference directoryPaths() {
return directoryPaths;
}
+
+ /**
+ * Returns the current project.
+ * @return the current project.
+ */
+ public IProject getProject() {
+ return project;
+ }
}
diff --git a/com.google.eclipse.protobuf.ui/src/com/google/eclipse/protobuf/ui/preferences/pages/paths/ProjectVariable.java b/com.google.eclipse.protobuf.ui/src/com/google/eclipse/protobuf/ui/preferences/paths/core/ProjectVariable.java
similarity index 73%
rename from com.google.eclipse.protobuf.ui/src/com/google/eclipse/protobuf/ui/preferences/pages/paths/ProjectVariable.java
rename to com.google.eclipse.protobuf.ui/src/com/google/eclipse/protobuf/ui/preferences/paths/core/ProjectVariable.java
index 10b4895..db922d9 100644
--- a/com.google.eclipse.protobuf.ui/src/com/google/eclipse/protobuf/ui/preferences/pages/paths/ProjectVariable.java
+++ b/com.google.eclipse.protobuf.ui/src/com/google/eclipse/protobuf/ui/preferences/paths/core/ProjectVariable.java
@@ -6,7 +6,7 @@
*
* http://www.eclipse.org/legal/epl-v10.html
*/
-package com.google.eclipse.protobuf.ui.preferences.pages.paths;
+package com.google.eclipse.protobuf.ui.preferences.paths.core;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.runtime.*;
@@ -16,17 +16,16 @@
*
* @author alruiz@google.com (Alex Ruiz)
*/
-class ProjectVariable {
+public class ProjectVariable {
private static final String VARIABLE_VALUE = "${project}";
- static IPath useProjectVariable(IPath path, IProject project) {
+ public static IPath replaceProjectNameWithProjectVariable(IPath path, IProject project) {
return switchProjectSegments(path, project.getName(), VARIABLE_VALUE);
}
- static String useProjectName(String path, IProject project) {
- IPath newPath = switchProjectSegments(new Path(path), VARIABLE_VALUE, project.getName());
- return newPath.toString();
+ public static IPath replaceProjectVariableWithProjectName(IPath path, IProject project) {
+ return switchProjectSegments(path, VARIABLE_VALUE, project.getName());
}
private static IPath switchProjectSegments(IPath path, String currentSegment, String newSegment) {
diff --git a/com.google.eclipse.protobuf.ui/src/com/google/eclipse/protobuf/ui/preferences/pages/paths/AddDirectoryDialog.java b/com.google.eclipse.protobuf.ui/src/com/google/eclipse/protobuf/ui/preferences/paths/page/AddDirectoryDialog.java
similarity index 87%
rename from com.google.eclipse.protobuf.ui/src/com/google/eclipse/protobuf/ui/preferences/pages/paths/AddDirectoryDialog.java
rename to com.google.eclipse.protobuf.ui/src/com/google/eclipse/protobuf/ui/preferences/paths/page/AddDirectoryDialog.java
index b60de32..c6d8845 100644
--- a/com.google.eclipse.protobuf.ui/src/com/google/eclipse/protobuf/ui/preferences/pages/paths/AddDirectoryDialog.java
+++ b/com.google.eclipse.protobuf.ui/src/com/google/eclipse/protobuf/ui/preferences/paths/page/AddDirectoryDialog.java
@@ -6,12 +6,11 @@
*
* http://www.eclipse.org/legal/epl-v10.html
*/
-package com.google.eclipse.protobuf.ui.preferences.pages.paths;
+package com.google.eclipse.protobuf.ui.preferences.paths.page;
import static com.google.eclipse.protobuf.ui.preferences.pages.TextWidgets.setEditable;
-import static com.google.eclipse.protobuf.ui.preferences.pages.paths.DirectorySelectionDialogs.*;
-import static com.google.eclipse.protobuf.ui.preferences.pages.paths.Messages.*;
-import static com.google.eclipse.protobuf.ui.preferences.pages.paths.ProjectVariable.useProjectVariable;
+import static com.google.eclipse.protobuf.ui.preferences.paths.page.DirectorySelectionDialogs.*;
+import static com.google.eclipse.protobuf.ui.preferences.paths.page.Messages.*;
import static org.eclipse.jface.dialogs.IDialogConstants.OK_ID;
import static org.eclipse.xtext.util.Strings.isEmpty;
@@ -23,6 +22,7 @@
import org.eclipse.swt.widgets.*;
import com.google.eclipse.protobuf.ui.preferences.pages.InputDialog;
+import com.google.eclipse.protobuf.ui.preferences.paths.core.ProjectVariable;
/**
* Dialog where users can select a path (in the workspace or file system) to be included in resolution of imports.
@@ -30,10 +30,11 @@
* @author alruiz@google.com (Alex Ruiz)
*/
public class AddDirectoryDialog extends InputDialog {
+ private static final String DIRECTORY_PATH_FORMAT = "${workspace_loc:%s}";
private final IProject project;
- private DirectoryPath selectedPath;
+ private String selectedPath;
private Text txtPath;
private Button btnWorkspace;
@@ -100,7 +101,7 @@
@Override public void widgetSelected(SelectionEvent e) {
IPath path = showWorkspaceDirectorySelectionDialog(getShell(), enteredPathText());
if (path != null) {
- path = useProjectVariable(path, project);
+ path = ProjectVariable.replaceProjectNameWithProjectVariable(path, project);
txtPath.setText(path.toString().trim());
btnIsWorkspacePath.setSelection(true);
}
@@ -132,7 +133,10 @@
/** {@inheritDoc} */
@Override protected void okPressed() {
- selectedPath = new DirectoryPath(enteredPathText(), btnIsWorkspacePath.getSelection());
+ selectedPath = enteredPathText();
+ if (btnIsWorkspacePath.getSelection()) {
+ selectedPath = String.format(DIRECTORY_PATH_FORMAT, selectedPath);
+ }
super.okPressed();
}
@@ -144,7 +148,7 @@
* Returns the path selected by the user.
* @return the path selected by the user.
*/
- public DirectoryPath selectedPath() {
+ public String selectedPath() {
return selectedPath;
}
}
diff --git a/com.google.eclipse.protobuf.ui/src/com/google/eclipse/protobuf/ui/preferences/pages/paths/DirectoryPathsEditor.java b/com.google.eclipse.protobuf.ui/src/com/google/eclipse/protobuf/ui/preferences/paths/page/DirectoryPathsEditor.java
similarity index 93%
rename from com.google.eclipse.protobuf.ui/src/com/google/eclipse/protobuf/ui/preferences/pages/paths/DirectoryPathsEditor.java
rename to com.google.eclipse.protobuf.ui/src/com/google/eclipse/protobuf/ui/preferences/paths/page/DirectoryPathsEditor.java
index f263259..8b4ad84 100644
--- a/com.google.eclipse.protobuf.ui/src/com/google/eclipse/protobuf/ui/preferences/pages/paths/DirectoryPathsEditor.java
+++ b/com.google.eclipse.protobuf.ui/src/com/google/eclipse/protobuf/ui/preferences/paths/page/DirectoryPathsEditor.java
@@ -6,9 +6,9 @@
*
* http://www.eclipse.org/legal/epl-v10.html
*/
-package com.google.eclipse.protobuf.ui.preferences.pages.paths;
+package com.google.eclipse.protobuf.ui.preferences.paths.page;
-import static com.google.eclipse.protobuf.ui.preferences.pages.paths.Messages.*;
+import static com.google.eclipse.protobuf.ui.preferences.paths.page.Messages.*;
import static java.util.Collections.unmodifiableList;
import static org.eclipse.jface.window.Window.OK;
@@ -25,6 +25,7 @@
import org.eclipse.xtext.ui.PluginImageHelper;
import com.google.eclipse.protobuf.ui.preferences.pages.DataChangedListener;
+import com.google.eclipse.protobuf.ui.preferences.paths.core.DirectoryPath;
/**
* Editor where users can add/remove the directories to be used for URI resolution.
@@ -42,7 +43,7 @@
private final Button btnUp;
private final Button btnDown;
- private final LinkedList<DirectoryPath> importPaths = new LinkedList<DirectoryPath>();
+ private final LinkedList<String> importPaths = new LinkedList<String>();
private DataChangedListener dataChangedListener;
@@ -69,7 +70,7 @@
tblclmnPath.setText(directories);
tblclmnVwrPath.setLabelProvider(new ColumnLabelProvider() {
@Override public String getText(Object element) {
- return ((DirectoryPath) element).toString();
+ return element.toString();
}
});
@@ -149,7 +150,7 @@
}
int target = goUp ? index - 1 : index + 1;
int[] selection = tblDirectoryPaths.getSelectionIndices();
- DirectoryPath path = importPaths.get(selection[0]);
+ String path = importPaths.get(selection[0]);
importPaths.remove(index);
importPaths.add(target, path);
updateTable();
@@ -181,11 +182,11 @@
btnDown.setEnabled(hasElements && hasSelection && selectionIndex < size - 1);
}
- public List<DirectoryPath> directoryPaths() {
+ public List<String> directoryPaths() {
return unmodifiableList(importPaths);
}
- public void directoryPaths(Collection<DirectoryPath> paths) {
+ public void directoryPaths(Collection<String> paths) {
importPaths.clear();
importPaths.addAll(paths);
updateTable();
diff --git a/com.google.eclipse.protobuf.ui/src/com/google/eclipse/protobuf/ui/preferences/pages/paths/DirectorySelectionDialogs.java b/com.google.eclipse.protobuf.ui/src/com/google/eclipse/protobuf/ui/preferences/paths/page/DirectorySelectionDialogs.java
similarity index 95%
rename from com.google.eclipse.protobuf.ui/src/com/google/eclipse/protobuf/ui/preferences/pages/paths/DirectorySelectionDialogs.java
rename to com.google.eclipse.protobuf.ui/src/com/google/eclipse/protobuf/ui/preferences/paths/page/DirectorySelectionDialogs.java
index c54435b..d9ec921 100644
--- a/com.google.eclipse.protobuf.ui/src/com/google/eclipse/protobuf/ui/preferences/pages/paths/DirectorySelectionDialogs.java
+++ b/com.google.eclipse.protobuf.ui/src/com/google/eclipse/protobuf/ui/preferences/paths/page/DirectorySelectionDialogs.java
@@ -6,10 +6,10 @@
*
* http://www.eclipse.org/legal/epl-v10.html
*/
-package com.google.eclipse.protobuf.ui.preferences.pages.paths;
+package com.google.eclipse.protobuf.ui.preferences.paths.page;
import static com.google.eclipse.protobuf.ui.ProtobufUiModule.PLUGIN_ID;
-import static com.google.eclipse.protobuf.ui.preferences.pages.paths.Messages.*;
+import static com.google.eclipse.protobuf.ui.preferences.paths.page.Messages.*;
import static org.eclipse.core.runtime.IStatus.ERROR;
import static org.eclipse.core.runtime.Status.OK_STATUS;
import static org.eclipse.jface.window.Window.OK;
diff --git a/com.google.eclipse.protobuf.ui/src/com/google/eclipse/protobuf/ui/preferences/pages/paths/Messages.java b/com.google.eclipse.protobuf.ui/src/com/google/eclipse/protobuf/ui/preferences/paths/page/Messages.java
similarity index 95%
rename from com.google.eclipse.protobuf.ui/src/com/google/eclipse/protobuf/ui/preferences/pages/paths/Messages.java
rename to com.google.eclipse.protobuf.ui/src/com/google/eclipse/protobuf/ui/preferences/paths/page/Messages.java
index 7da1a40..f316483 100644
--- a/com.google.eclipse.protobuf.ui/src/com/google/eclipse/protobuf/ui/preferences/pages/paths/Messages.java
+++ b/com.google.eclipse.protobuf.ui/src/com/google/eclipse/protobuf/ui/preferences/paths/page/Messages.java
@@ -6,7 +6,7 @@
*
* http://www.eclipse.org/legal/epl-v10.html
*/
-package com.google.eclipse.protobuf.ui.preferences.pages.paths;
+package com.google.eclipse.protobuf.ui.preferences.paths.page;
import org.eclipse.osgi.util.NLS;
diff --git a/com.google.eclipse.protobuf.ui/src/com/google/eclipse/protobuf/ui/preferences/pages/paths/Messages.properties b/com.google.eclipse.protobuf.ui/src/com/google/eclipse/protobuf/ui/preferences/paths/page/Messages.properties
similarity index 100%
rename from com.google.eclipse.protobuf.ui/src/com/google/eclipse/protobuf/ui/preferences/pages/paths/Messages.properties
rename to com.google.eclipse.protobuf.ui/src/com/google/eclipse/protobuf/ui/preferences/paths/page/Messages.properties
diff --git a/com.google.eclipse.protobuf.ui/src/com/google/eclipse/protobuf/ui/preferences/pages/paths/PathsPreferencePage.java b/com.google.eclipse.protobuf.ui/src/com/google/eclipse/protobuf/ui/preferences/paths/page/PathsPreferencePage.java
similarity index 86%
rename from com.google.eclipse.protobuf.ui/src/com/google/eclipse/protobuf/ui/preferences/pages/paths/PathsPreferencePage.java
rename to com.google.eclipse.protobuf.ui/src/com/google/eclipse/protobuf/ui/preferences/paths/page/PathsPreferencePage.java
index 37d9954..acfb64c 100644
--- a/com.google.eclipse.protobuf.ui/src/com/google/eclipse/protobuf/ui/preferences/pages/paths/PathsPreferencePage.java
+++ b/com.google.eclipse.protobuf.ui/src/com/google/eclipse/protobuf/ui/preferences/paths/page/PathsPreferencePage.java
@@ -6,12 +6,12 @@
*
* http://www.eclipse.org/legal/epl-v10.html
*/
-package com.google.eclipse.protobuf.ui.preferences.pages.paths;
+package com.google.eclipse.protobuf.ui.preferences.paths.page;
import static com.google.eclipse.protobuf.ui.ProtobufUiModule.PLUGIN_ID;
import static com.google.eclipse.protobuf.ui.preferences.pages.ButtonGroup.with;
import static com.google.eclipse.protobuf.ui.preferences.pages.binding.BindingToButtonSelection.bindSelectionOf;
-import static com.google.eclipse.protobuf.ui.preferences.pages.paths.Messages.*;
+import static com.google.eclipse.protobuf.ui.preferences.paths.page.Messages.*;
import static java.util.Collections.unmodifiableList;
import static org.eclipse.core.resources.IncrementalProjectBuilder.FULL_BUILD;
import static org.eclipse.core.runtime.Status.OK_STATUS;
@@ -30,9 +30,9 @@
import org.eclipse.swt.widgets.*;
import org.eclipse.xtext.ui.PluginImageHelper;
-import com.google.eclipse.protobuf.ui.preferences.*;
import com.google.eclipse.protobuf.ui.preferences.pages.*;
import com.google.eclipse.protobuf.ui.preferences.pages.binding.*;
+import com.google.eclipse.protobuf.ui.preferences.paths.core.PathsPreferences;
import com.google.eclipse.protobuf.ui.validation.ValidationTrigger;
import com.google.inject.Inject;
@@ -42,7 +42,6 @@
* @author alruiz@google.com (Alex Ruiz)
*/
public class PathsPreferencePage extends PreferenceAndPropertyPage {
-
private static Logger logger = Logger.getLogger(PathsPreferencePage.class);
private static final String COMMA_DELIMITER = ",";
@@ -116,45 +115,42 @@
}
@Override protected void setupBinding(PreferenceBinder preferenceBinder) {
- RawPreferences preferences = new RawPreferences(getPreferenceStore());
- preferenceBinder.addAll(bindSelectionOf(btnOneDirectoryOnly).to(preferences.filesInOneDirectoryOnly()),
- bindSelectionOf(btnMultipleDirectories).to(preferences.filesInMultipleDirectories()));
- final StringPreference directoryPaths = preferences.directoryPaths();
+ final PathsPreferences preferences = new PathsPreferences(getPreferenceStore());
+ preferenceBinder.addAll(
+ bindSelectionOf(btnOneDirectoryOnly).to(preferences.filesInOneDirectoryOnly()),
+ bindSelectionOf(btnMultipleDirectories).to(preferences.filesInMultipleDirectories())
+ );
preferenceBinder.add(new Binding() {
@Override public void applyPreferenceValueToTarget() {
- setDirectoryPaths(directoryPaths.getValue());
+ setDirectoryPaths(preferences.directoryPaths().getValue());
}
@Override public void applyDefaultPreferenceValueToTarget() {
- setDirectoryPaths(directoryPaths.getDefaultValue());
+ setDirectoryPaths(preferences.directoryPaths().getDefaultValue());
}
@Override public void savePreferenceValue() {
- directoryPaths.setValue(directoryNames());
+ preferences.directoryPaths().setValue(directoryNames());
}
});
}
private String directoryNames() {
- List<DirectoryPath> paths = directoryPathsEditor.directoryPaths();
+ List<String> paths = directoryPathsEditor.directoryPaths();
if (paths.isEmpty())
{
return "";
}
- List<String> pathsAsText = new ArrayList<String>();
- for (DirectoryPath path : paths) {
- pathsAsText.add(path.toString());
- }
- return concat(COMMA_DELIMITER, pathsAsText);
+ return concat(COMMA_DELIMITER, paths);
}
private void setDirectoryPaths(String directoryPaths) {
- List<DirectoryPath> paths = new ArrayList<DirectoryPath>();
+ List<String> paths = new ArrayList<String>();
for (String path : split(directoryPaths, COMMA_DELIMITER)) {
if (isEmpty(path)) {
continue;
}
- paths.add(DirectoryPath.parse(path));
+ paths.add(path);
}
directoryPathsEditor.directoryPaths(unmodifiableList(paths));
}
diff --git a/com.google.eclipse.protobuf.ui/src/com/google/eclipse/protobuf/ui/scoping/FileResolverStrategies.java b/com.google.eclipse.protobuf.ui/src/com/google/eclipse/protobuf/ui/scoping/FileResolverStrategies.java
index 15ed6e9..32c088a 100644
--- a/com.google.eclipse.protobuf.ui/src/com/google/eclipse/protobuf/ui/scoping/FileResolverStrategies.java
+++ b/com.google.eclipse.protobuf.ui/src/com/google/eclipse/protobuf/ui/scoping/FileResolverStrategies.java
@@ -8,28 +8,27 @@
*/
package com.google.eclipse.protobuf.ui.scoping;
-import static com.google.eclipse.protobuf.ui.preferences.pages.paths.PathResolutionType.*;
-
-import java.util.*;
-
-import com.google.eclipse.protobuf.ui.preferences.pages.paths.PathResolutionType;
import com.google.eclipse.protobuf.ui.util.Resources;
-import com.google.inject.*;
+import com.google.inject.Inject;
/**
* @author alruiz@google.com (Alex Ruiz)
*/
-@Singleton class FileResolverStrategies {
+class FileResolverStrategies {
- private final Map<PathResolutionType, FileResolverStrategy> strategies =
- new HashMap<PathResolutionType, FileResolverStrategy>();
+ private final FileResolverStrategy singleDirectory;
+ private final FileResolverStrategy multipleDirectories;
@Inject FileResolverStrategies(PathMapping mapping, Resources resources) {
- strategies.put(SINGLE_DIRECTORY, new SingleDirectoryFileResolver(resources));
- strategies.put(MULTIPLE_DIRECTORIES, new MultipleDirectoriesFileResolver(mapping, resources));
+ singleDirectory = new SingleDirectoryFileResolver(resources);
+ multipleDirectories = new MultipleDirectoriesFileResolver(mapping, resources);
}
- FileResolverStrategy strategyFor(PathResolutionType type) {
- return strategies.get(type);
+ FileResolverStrategy singleDirectory() {
+ return singleDirectory;
+ }
+
+ FileResolverStrategy multipleDirectories() {
+ return multipleDirectories;
}
}
diff --git a/com.google.eclipse.protobuf.ui/src/com/google/eclipse/protobuf/ui/scoping/FileResolverStrategy.java b/com.google.eclipse.protobuf.ui/src/com/google/eclipse/protobuf/ui/scoping/FileResolverStrategy.java
index 9310ccd..b639d3e 100644
--- a/com.google.eclipse.protobuf.ui/src/com/google/eclipse/protobuf/ui/scoping/FileResolverStrategy.java
+++ b/com.google.eclipse.protobuf.ui/src/com/google/eclipse/protobuf/ui/scoping/FileResolverStrategy.java
@@ -11,7 +11,7 @@
import org.eclipse.core.runtime.IPath;
import org.eclipse.emf.common.util.URI;
-import com.google.eclipse.protobuf.ui.preferences.pages.paths.PathsPreferences;
+import com.google.eclipse.protobuf.ui.preferences.paths.core.PathsPreferences;
/**
* @author alruiz@google.com (Alex Ruiz)
diff --git a/com.google.eclipse.protobuf.ui/src/com/google/eclipse/protobuf/ui/scoping/FileUriResolver.java b/com.google.eclipse.protobuf.ui/src/com/google/eclipse/protobuf/ui/scoping/FileUriResolver.java
index a8de8d1..2e0e03d 100644
--- a/com.google.eclipse.protobuf.ui/src/com/google/eclipse/protobuf/ui/scoping/FileUriResolver.java
+++ b/com.google.eclipse.protobuf.ui/src/com/google/eclipse/protobuf/ui/scoping/FileUriResolver.java
@@ -13,9 +13,10 @@
import org.eclipse.core.resources.IProject;
import org.eclipse.emf.common.util.URI;
import org.eclipse.emf.ecore.resource.Resource;
+import org.eclipse.xtext.ui.editor.preferences.IPreferenceStoreAccess;
import com.google.eclipse.protobuf.scoping.*;
-import com.google.eclipse.protobuf.ui.preferences.pages.paths.*;
+import com.google.eclipse.protobuf.ui.preferences.paths.core.PathsPreferences;
import com.google.eclipse.protobuf.ui.util.Resources;
import com.google.inject.Inject;
@@ -26,10 +27,10 @@
*/
public class FileUriResolver implements IFileUriResolver {
- @Inject private PathsPreferencesFactory preferencesFactory;
- @Inject private FileResolverStrategies resolvers;
@Inject private ProtoDescriptorProvider descriptorProvider;
@Inject private Resources resources;
+ @Inject private IPreferenceStoreAccess storeAccess;
+ @Inject private FileResolverStrategies resolvers;
/*
* The import URI is relative to the file where the import is. Protoc works fine, but the editor doesn't.
@@ -71,11 +72,14 @@
if (project == null) {
throw new IllegalStateException("Unable to find current project");
}
- PathsPreferences preferences = preferencesFactory.preferences(project);
+ PathsPreferences preferences = new PathsPreferences(storeAccess, project);
return resolver(preferences).resolveUri(importUri, resourceUri, preferences);
}
private FileResolverStrategy resolver(PathsPreferences preferences) {
- return resolvers.strategyFor(preferences.pathResolutionType());
+ if (preferences.filesInOneDirectoryOnly().getValue()) {
+ return resolvers.singleDirectory();
+ }
+ return resolvers.multipleDirectories();
}
}
diff --git a/com.google.eclipse.protobuf.ui/src/com/google/eclipse/protobuf/ui/scoping/MultipleDirectoriesFileResolver.java b/com.google.eclipse.protobuf.ui/src/com/google/eclipse/protobuf/ui/scoping/MultipleDirectoriesFileResolver.java
index 05bd6c8..da52eb4 100644
--- a/com.google.eclipse.protobuf.ui/src/com/google/eclipse/protobuf/ui/scoping/MultipleDirectoriesFileResolver.java
+++ b/com.google.eclipse.protobuf.ui/src/com/google/eclipse/protobuf/ui/scoping/MultipleDirectoriesFileResolver.java
@@ -8,21 +8,22 @@
*/
package com.google.eclipse.protobuf.ui.scoping;
-import java.util.List;
+import static com.google.eclipse.protobuf.ui.util.CommaSeparatedValues.splitCsv;
+
+import java.util.*;
import org.eclipse.core.filesystem.*;
import org.eclipse.core.filesystem.URIUtil;
import org.eclipse.core.runtime.*;
import org.eclipse.emf.common.util.URI;
-import com.google.eclipse.protobuf.ui.preferences.pages.paths.*;
+import com.google.eclipse.protobuf.ui.preferences.paths.core.*;
import com.google.eclipse.protobuf.ui.util.Resources;
/**
* @author alruiz@google.com (Alex Ruiz)
*/
class MultipleDirectoriesFileResolver implements FileResolverStrategy {
-
private final PathMapping mapping;
private final Resources resources;
@@ -33,18 +34,20 @@
/** {@inheritDoc} */
@Override public String resolveUri(String importUri, URI declaringResourceUri, PathsPreferences preferences) {
- List<DirectoryPath> importRoots = preferences.importRoots();
- for (DirectoryPath root : importRoots) {
- String resolved = resolveUri(importUri, root);
+ String directoryPaths = preferences.directoryPaths().getValue();
+ List<String> fileSystemDirectories = new ArrayList<String>();
+ for (String importRoot : splitCsv(directoryPaths)) {
+ DirectoryPath path = DirectoryPath.parse(importRoot, preferences.getProject());
+ String resolved = resolveUri(importUri, path);
if (resolved != null) {
return resolved;
}
- }
- for (DirectoryPath root : importRoots) {
- if (!root.isWorkspacePath()) {
- continue;
+ if (!path.isWorkspacePath()) {
+ fileSystemDirectories.add(path.value());
}
- String resolved = resolveUriInFileSystem(importUri, mapping.folderLocation(root.value()));
+ }
+ for (String root : fileSystemDirectories) {
+ String resolved = resolveUriInFileSystem(importUri, mapping.folderLocation(root));
if (resolved != null) {
return resolved;
}
@@ -52,23 +55,23 @@
return null;
}
- private String resolveUri(String importUri, DirectoryPath importRoot) {
- String root = importRoot.value();
- if (importRoot.isWorkspacePath()) {
+ private String resolveUri(String importUri, DirectoryPath importRootPath) {
+ String root = importRootPath.value();
+ if (importRootPath.isWorkspacePath()) {
return resolveUriInWorkspace(importUri, root);
}
return resolveUriInFileSystem(importUri, root);
}
- private String resolveUriInWorkspace(String importUri, String importRoot) {
- String path = PLATFORM_RESOURCE_PREFIX + importRoot + SEPARATOR + importUri;
+ private String resolveUriInWorkspace(String importUri, String importRootPath) {
+ String path = PLATFORM_RESOURCE_PREFIX + importRootPath + SEPARATOR + importUri;
boolean exists = resources.fileExists(URI.createURI(path));
return (exists) ? path : null;
}
- private String resolveUriInFileSystem(String importUri, String importRoot) {
+ private String resolveUriInFileSystem(String importUri, String importRootPath) {
IFileSystem fileSystem = EFS.getLocalFileSystem();
- IPath path = new Path(importRoot + SEPARATOR + importUri);
+ IPath path = new Path(importRootPath + SEPARATOR + importUri);
IFileInfo fileInfo = fileSystem.getStore(path).fetchInfo();
if (!fileInfo.exists()) {
return null;
diff --git a/com.google.eclipse.protobuf.ui/src/com/google/eclipse/protobuf/ui/scoping/PathMapping.java b/com.google.eclipse.protobuf.ui/src/com/google/eclipse/protobuf/ui/scoping/PathMapping.java
index faa741a..57bf5c6 100644
--- a/com.google.eclipse.protobuf.ui/src/com/google/eclipse/protobuf/ui/scoping/PathMapping.java
+++ b/com.google.eclipse.protobuf.ui/src/com/google/eclipse/protobuf/ui/scoping/PathMapping.java
@@ -27,10 +27,10 @@
private static class FolderPathMapper implements Function<String, String> {
@Override public String apply(String workspacePath) {
- return folder(workspacePath).getLocation().toOSString();
+ return directory(workspacePath).getLocation().toOSString();
}
- private static IFolder folder(String workspacePath) {
+ private static IFolder directory(String workspacePath) {
IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
return root.getFolder(new Path(workspacePath));
}
diff --git a/com.google.eclipse.protobuf.ui/src/com/google/eclipse/protobuf/ui/scoping/SingleDirectoryFileResolver.java b/com.google.eclipse.protobuf.ui/src/com/google/eclipse/protobuf/ui/scoping/SingleDirectoryFileResolver.java
index d99f27c..5967b1f 100644
--- a/com.google.eclipse.protobuf.ui/src/com/google/eclipse/protobuf/ui/scoping/SingleDirectoryFileResolver.java
+++ b/com.google.eclipse.protobuf.ui/src/com/google/eclipse/protobuf/ui/scoping/SingleDirectoryFileResolver.java
@@ -14,7 +14,7 @@
import org.eclipse.emf.common.util.URI;
-import com.google.eclipse.protobuf.ui.preferences.pages.paths.PathsPreferences;
+import com.google.eclipse.protobuf.ui.preferences.paths.core.PathsPreferences;
import com.google.eclipse.protobuf.ui.util.Resources;
/**
diff --git a/com.google.eclipse.protobuf.ui/src/com/google/eclipse/protobuf/ui/util/CommaSeparatedValues.java b/com.google.eclipse.protobuf.ui/src/com/google/eclipse/protobuf/ui/util/CommaSeparatedValues.java
new file mode 100644
index 0000000..0a07698
--- /dev/null
+++ b/com.google.eclipse.protobuf.ui/src/com/google/eclipse/protobuf/ui/util/CommaSeparatedValues.java
@@ -0,0 +1,29 @@
+/*
+ * 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;
+
+/**
+ * Utility methods related to comma-separated values.
+ *
+ * @author alruiz@google.com (Alex Ruiz)
+ */
+public final class CommaSeparatedValues {
+ private static final String CSV_PATTERN = "[\\s]*,[\\s]*";
+
+ /**
+ * Splits the given {@code String} containing comma-separated values.
+ * @param s the given {@code String}.
+ * @return an array containing an element per value in the given {@code String}.
+ */
+ public static String[] splitCsv(String s) {
+ return s.split(CSV_PATTERN);
+ }
+
+ private CommaSeparatedValues() {}
+}