In progress: [ Issue 40 ] Add support for import resolution across multiple folders
https://code.google.com/p/protobuf-dt/issues/detail?id=40
Adding a preference page for import paths.
diff --git a/com.google.eclipse.protobuf.ui/OSGI-INF/l10n/bundle.properties b/com.google.eclipse.protobuf.ui/OSGI-INF/l10n/bundle.properties
index 6feb38a..dbc0008 100644
--- a/com.google.eclipse.protobuf.ui/OSGI-INF/l10n/bundle.properties
+++ b/com.google.eclipse.protobuf.ui/OSGI-INF/l10n/bundle.properties
@@ -6,7 +6,7 @@
page.name.0 = Syntax Coloring
page.name.1 = Templates
page.name.2 = Compiler
-page.name.3 = Protocol Buffer Compiler
+page.name.3 = Paths
keyword.label = Protocol Buffer
command.description = Trigger expensive validation
command.name = Validate
diff --git a/com.google.eclipse.protobuf.ui/plugin.xml b/com.google.eclipse.protobuf.ui/plugin.xml
index dc50779..75efb54 100644
--- a/com.google.eclipse.protobuf.ui/plugin.xml
+++ b/com.google.eclipse.protobuf.ui/plugin.xml
@@ -48,7 +48,7 @@
</extension>
<extension point="org.eclipse.ui.preferencePages">
<page
- class="com.google.eclipse.protobuf.ui.ProtobufExecutableExtensionFactory:org.eclipse.xtext.ui.editor.preferences.LanguageRootPreferencePage"
+ class="com.google.eclipse.protobuf.ui.ProtobufExecutableExtensionFactory:com.google.eclipse.protobuf.ui.preferences.RootPreferencePage"
id="com.google.eclipse.protobuf.Protobuf" name="%page.name">
<keywordReference id="com.google.eclipse.protobuf.ui.keyword_Protobuf" />
</page>
@@ -67,6 +67,11 @@
id="com.google.eclipse.protobuf.ui.preferences.compiler.PreferencePage" name="%page.name.2">
<keywordReference id="com.google.eclipse.protobuf.ui.keyword_Protobuf" />
</page>
+ <page category="com.google.eclipse.protobuf.Protobuf"
+ class="com.google.eclipse.protobuf.ui.ProtobufExecutableExtensionFactory:com.google.eclipse.protobuf.ui.preferences.paths.PreferencePage"
+ id="com.google.eclipse.protobuf.ui.preferences.paths.PreferencePage" name="%page.name.3">
+ <keywordReference id="com.google.eclipse.protobuf.ui.keyword_Protobuf" />
+ </page>
</extension>
<extension point="org.eclipse.ui.keywords">
<keyword id="com.google.eclipse.protobuf.ui.keyword_Protobuf" label="%keyword.label" />
@@ -161,8 +166,23 @@
</extension>
<extension point="org.eclipse.ui.propertyPages">
<page
- class="com.google.eclipse.protobuf.ui.ProtobufExecutableExtensionFactory:com.google.eclipse.protobuf.ui.preferences.compiler.PreferencePage"
- id="com.google.eclipse.protobuf.ui.properties.compiler.PropertyPage" name="%page.name.3" selectionFilter="single">
+ class="com.google.eclipse.protobuf.ui.ProtobufExecutableExtensionFactory:com.google.eclipse.protobuf.ui.preferences.RootPreferencePage"
+ id="com.google.eclipse.protobuf.Protobuf"
+ name="%page.name" selectionFilter="single">
+ </page>
+ <page
+ category="com.google.eclipse.protobuf.Protobuf"
+ class="com.google.eclipse.protobuf.ui.ProtobufExecutableExtensionFactory:com.google.eclipse.protobuf.ui.preferences.compiler.PreferencePage"
+ id="com.google.eclipse.protobuf.ui.properties.compiler.PropertyPage"
+ name="%page.name.2"
+ selectionFilter="single">
+ </page>
+ <page
+ category="com.google.eclipse.protobuf.Protobuf"
+ class="com.google.eclipse.protobuf.ui.ProtobufExecutableExtensionFactory:com.google.eclipse.protobuf.ui.preferences.paths.PreferencePage"
+ id="com.google.eclipse.protobuf.ui.properties.paths.PropertyPage"
+ name="%page.name.3"
+ selectionFilter="single">
</page>
</extension>
<extension point="org.eclipse.xtext.builder.participant">
diff --git a/com.google.eclipse.protobuf.ui/src/com/google/eclipse/protobuf/ui/preferences/PreferenceAndPropertyPage.java b/com.google.eclipse.protobuf.ui/src/com/google/eclipse/protobuf/ui/preferences/PreferenceAndPropertyPage.java
index ebae962..0891d2e 100644
--- a/com.google.eclipse.protobuf.ui/src/com/google/eclipse/protobuf/ui/preferences/PreferenceAndPropertyPage.java
+++ b/com.google.eclipse.protobuf.ui/src/com/google/eclipse/protobuf/ui/preferences/PreferenceAndPropertyPage.java
@@ -23,8 +23,7 @@
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.*;
-import org.eclipse.ui.IWorkbenchPreferencePage;
-import org.eclipse.ui.IWorkbenchPropertyPage;
+import org.eclipse.ui.*;
import org.eclipse.xtext.ui.editor.preferences.IPreferenceStoreAccess;
import com.google.inject.Inject;
@@ -173,4 +172,17 @@
protected final boolean areProjectSettingsActive() {
return btnEnableProjectSettings.getSelection();
}
+
+ /** {@inheritDoc} */
+ public void init(IWorkbench workbench) {}
+
+ @Override public final boolean performOk() {
+ savePreferences();
+ return true;
+ }
+
+ /**
+ * Saves the current settings.
+ */
+ protected abstract void savePreferences();
}
diff --git a/com.google.eclipse.protobuf.ui/src/com/google/eclipse/protobuf/ui/preferences/RootPreferencePage.java b/com.google.eclipse.protobuf.ui/src/com/google/eclipse/protobuf/ui/preferences/RootPreferencePage.java
new file mode 100644
index 0000000..559cfb6
--- /dev/null
+++ b/com.google.eclipse.protobuf.ui/src/com/google/eclipse/protobuf/ui/preferences/RootPreferencePage.java
@@ -0,0 +1,47 @@
+/*
+ * 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;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.widgets.*;
+import org.eclipse.xtext.ui.editor.preferences.IPreferenceStoreAccess;
+
+import com.google.inject.Inject;
+
+/**
+ * @author alruiz@google.com (Alex Ruiz)
+ */
+public class RootPreferencePage extends PreferenceAndPropertyPage {
+
+ private static final String PREFERENCE_PAGE_ID = RootPreferencePage.class.getName();
+
+ @Inject public RootPreferencePage(IPreferenceStoreAccess preferenceStoreAccess) {
+ super(preferenceStoreAccess);
+ }
+
+ /** {@inheritDoc} */
+ @Override protected Control createContents(Composite parent) {
+ // generated by WindowBuilder
+ Composite contents = super.contentsComposite(parent);
+ Label label = new Label(contents, SWT.NONE);
+ label.setText("General Settings.");
+ return contents;
+ }
+
+ /** {@inheritDoc} */
+ @Override protected void onProjectSettingsActivation(boolean active) {}
+
+ /** {@inheritDoc} */
+ @Override protected String preferencePageId() {
+ return PREFERENCE_PAGE_ID;
+ }
+
+ /** {@inheritDoc} */
+ @Override protected void savePreferences() {}
+}
diff --git a/com.google.eclipse.protobuf.ui/src/com/google/eclipse/protobuf/ui/preferences/compiler/PreferencePage.java b/com.google.eclipse.protobuf.ui/src/com/google/eclipse/protobuf/ui/preferences/compiler/PreferencePage.java
index 78dbdf7..2b1326b 100644
--- a/com.google.eclipse.protobuf.ui/src/com/google/eclipse/protobuf/ui/preferences/compiler/PreferencePage.java
+++ b/com.google.eclipse.protobuf.ui/src/com/google/eclipse/protobuf/ui/preferences/compiler/PreferencePage.java
@@ -24,7 +24,6 @@
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.*;
-import org.eclipse.ui.IWorkbench;
import org.eclipse.xtext.ui.editor.preferences.IPreferenceStoreAccess;
import com.google.eclipse.protobuf.ui.preferences.PreferenceAndPropertyPage;
@@ -69,7 +68,6 @@
@Override protected Control createContents(Composite parent) {
// generated by WindowBuilder
Composite contents = contentsComposite(parent);
- contents.setLayout(new GridLayout(3, false));
btnCompileProtoFiles = new Button(contents, SWT.CHECK);
btnCompileProtoFiles.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, true, false, 2, 1));
@@ -358,14 +356,7 @@
}
/** {@inheritDoc} */
- public void init(IWorkbench workbench) {}
-
- @Override public boolean performOk() {
- savePreferences();
- return true;
- }
-
- private void savePreferences() {
+ @Override protected void savePreferences() {
IPreferenceStore store = getPreferenceStore();
if (isPropertyPage()) {
store.setValue(ENABLE_PROJECT_SETTINGS, areProjectSettingsActive());
@@ -384,8 +375,8 @@
}
/** {@inheritDoc} */
- @Override protected void onProjectSettingsActivation(boolean projectSettingsEnabled) {
- setProjectSpecificOptionsEnabled(projectSettingsEnabled);
+ @Override protected void onProjectSettingsActivation(boolean active) {
+ setProjectSpecificOptionsEnabled(active);
setCompilerOptionsEnabled(isEnabledAndSelected(btnCompileProtoFiles));
}
diff --git a/com.google.eclipse.protobuf.ui/src/com/google/eclipse/protobuf/ui/preferences/paths/PreferencePage.java b/com.google.eclipse.protobuf.ui/src/com/google/eclipse/protobuf/ui/preferences/paths/PreferencePage.java
new file mode 100644
index 0000000..9513c36
--- /dev/null
+++ b/com.google.eclipse.protobuf.ui/src/com/google/eclipse/protobuf/ui/preferences/paths/PreferencePage.java
@@ -0,0 +1,78 @@
+/*
+ * 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;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.*;
+import org.eclipse.xtext.ui.editor.preferences.IPreferenceStoreAccess;
+
+import com.google.eclipse.protobuf.ui.preferences.PreferenceAndPropertyPage;
+import com.google.inject.Inject;
+
+/**
+ * @author alruiz@google.com (Alex Ruiz)
+ *
+ */
+public class PreferencePage extends PreferenceAndPropertyPage {
+
+ private static final String PREFERENCE_PAGE_ID = PreferencePage.class.getName();
+
+ private Group grpResolutionOfImported;
+ private Button btnOneFolderFor;
+ private Button btnLookForImported;
+ private Text txtFolderNames;
+
+ @Inject public PreferencePage(IPreferenceStoreAccess preferenceStoreAccess) {
+ super(preferenceStoreAccess);
+ }
+
+ /** {@inheritDoc} */
+ @Override protected Control createContents(Composite parent) {
+ // generated by WindowBuilder
+ Composite contents = contentsComposite(parent);
+
+ grpResolutionOfImported = new Group(contents, SWT.NONE);
+ grpResolutionOfImported.setLayout(new GridLayout(1, false));
+ grpResolutionOfImported.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 2, 1));
+ grpResolutionOfImported.setText("Resolution of imported files");
+
+ btnOneFolderFor = new Button(grpResolutionOfImported, SWT.RADIO);
+ btnOneFolderFor.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, true, false, 1, 1));
+ btnOneFolderFor.setText("One folder for all .proto files");
+
+ btnLookForImported = new Button(grpResolutionOfImported, SWT.RADIO);
+ btnLookForImported.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, true, false, 1, 1));
+ btnLookForImported.setText("Look for imported files in folders:");
+
+ txtFolderNames = new Text(grpResolutionOfImported, SWT.BORDER);
+ txtFolderNames.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
+ new Label(contents, SWT.NONE);
+ return contents;
+ }
+
+ /** {@inheritDoc} */
+ @Override protected void onProjectSettingsActivation(boolean active) {
+ // TODO Auto-generated method stub
+
+ }
+
+ /** {@inheritDoc} */
+ @Override protected String preferencePageId() {
+ return PREFERENCE_PAGE_ID;
+ }
+
+ /** {@inheritDoc} */
+ @Override protected void savePreferences() {
+ // TODO Auto-generated method stub
+
+ }
+
+}