Fixed: [Issue 103] Integration with protoc - Error message: "'the
selected file is not protoc" when I point to 'protoc.exe'
diff --git a/com.google.eclipse.protobuf.ui/src/com/google/eclipse/protobuf/ui/preferences/pages/compiler/CompilerPreferencePage.java b/com.google.eclipse.protobuf.ui/src/com/google/eclipse/protobuf/ui/preferences/pages/compiler/CompilerPreferencePage.java
index 4009ecd..9649ea5 100644
--- a/com.google.eclipse.protobuf.ui/src/com/google/eclipse/protobuf/ui/preferences/pages/compiler/CompilerPreferencePage.java
+++ b/com.google.eclipse.protobuf.ui/src/com/google/eclipse/protobuf/ui/preferences/pages/compiler/CompilerPreferencePage.java
@@ -37,8 +37,6 @@
* @author alruiz@google.com (Alex Ruiz)
*/
public class CompilerPreferencePage extends PreferenceAndPropertyPage {
- public CompilerPreferencePage() {
- }
private static final String PREFERENCE_PAGE_ID = CompilerPreferencePage.class.getName();
@@ -209,22 +207,27 @@
pageIsNowInvalid(errorNoSelection);
return;
}
- if (!isFileWithName(protocPath, "protoc")) {
+ if (!isFileWithNames(protocPath, "protoc", "protoc.exe")) {
pageIsNowInvalid(errorInvalidProtoc);
return;
}
}
String descriptorPath = txtDescriptorFilePath.getText();
- if (!isEmpty(descriptorPath) && !isFileWithName(descriptorPath, "descriptor.proto")) {
+ if (!isEmpty(descriptorPath) && !isFileWithNames(descriptorPath, "descriptor.proto")) {
pageIsNowInvalid(errorInvalidDescriptor);
return;
}
pageIsNowValid();
}
- private boolean isFileWithName(String filePath, String expectedFileName) {
+ private boolean isFileWithNames(String filePath, String... expectedFileNames) {
File file = new File(filePath);
- return file.isFile() && expectedFileName.equals(file.getName());
+ if (!file.isFile()) return false;
+ String fileName = file.getName();
+ for (String name : expectedFileNames) {
+ if (name.equals(fileName)) return true;
+ }
+ return false;
}
@Override protected BooleanPreference enableProjectSettingsPreference(IPreferenceStore store) {