aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCheng Chen2012-04-28 06:54:11 (EDT)
committerCheng Chen2012-04-28 06:54:11 (EDT)
commit134206e70e179989515ad1e7e83ab7dd29e7c7b2 (patch)
tree1f8f929e93356c7ad4077a78780efb9d93e65f14
parentb0d738a577f49b876040e247262cad8fdc73e22b (diff)
downloadorg.eclipse.recommenders-134206e70e179989515ad1e7e83ab7dd29e7c7b2.zip
org.eclipse.recommenders-134206e70e179989515ad1e7e83ab7dd29e7c7b2.tar.gz
org.eclipse.recommenders-134206e70e179989515ad1e7e83ab7dd29e7c7b2.tar.bz2
[snipmatch] Add Eclipse preference pages for SnipMatch local searchrefs/changes/84/5684/3
module This module include local snippets directory setting, index file setting UI and remove useless annotate code snippets Signed-off-by: Cheng Chen <chengchendoc@gmail.com> Change-Id: Ibde4ca85f4615a1737229afa43c45f4ca4e0895b
-rw-r--r--[-rwxr-xr-x]plugins/org.eclipse.recommenders.snipmatch.rcp/META-INF/MANIFEST.MF45
-rw-r--r--plugins/org.eclipse.recommenders.snipmatch.rcp/plugin.xml21
-rw-r--r--plugins/org.eclipse.recommenders.snipmatch.rcp/src/org/eclipse/recommenders/snipmatch/preferences/GitRepositorySettingPreferencePage.java92
-rw-r--r--plugins/org.eclipse.recommenders.snipmatch.rcp/src/org/eclipse/recommenders/snipmatch/preferences/PreferenceConstants.java20
-rw-r--r--plugins/org.eclipse.recommenders.snipmatch.rcp/src/org/eclipse/recommenders/snipmatch/preferences/PreferenceInitializer.java49
-rw-r--r--plugins/org.eclipse.recommenders.snipmatch.rcp/src/org/eclipse/recommenders/snipmatch/preferences/SnipMatchPreferencePage.java43
6 files changed, 250 insertions, 20 deletions
diff --git a/plugins/org.eclipse.recommenders.snipmatch.rcp/META-INF/MANIFEST.MF b/plugins/org.eclipse.recommenders.snipmatch.rcp/META-INF/MANIFEST.MF
index 2423892..47f2f9a 100755..100644
--- a/plugins/org.eclipse.recommenders.snipmatch.rcp/META-INF/MANIFEST.MF
+++ b/plugins/org.eclipse.recommenders.snipmatch.rcp/META-INF/MANIFEST.MF
@@ -1,20 +1,25 @@
-Manifest-Version: 1.0
-Bundle-ManifestVersion: 2
-Bundle-Name: SnipMatch
-Bundle-SymbolicName: org.eclipse.recommenders.snipmatch;singleton:=true
-Bundle-Version: 1.0.0
-Bundle-Activator: org.eclipse.recommenders.snipmatch.rcp.SnipMatchPlugin
-Bundle-Vendor: SnipMatch
-Require-Bundle: org.eclipse.ui,
- org.eclipse.core.runtime,
- org.eclipse.jface.text;bundle-version="3.6.1",
- org.eclipse.jdt.core;bundle-version="3.6.1",
- org.eclipse.core.resources;bundle-version="3.6.0",
- org.eclipse.jdt.ui;bundle-version="3.6.2",
- org.apache.commons.httpclient;bundle-version="3.1.0"
-Bundle-RequiredExecutionEnvironment: JavaSE-1.6
-Bundle-ActivationPolicy: lazy
-Bundle-ClassPath: .
-Import-Package: org.eclipse.core.expressions,
- org.eclipse.ui.internal.texteditor.quickdiff,
- org.eclipse.ui.texteditor
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: Code Recommenders: SnipMatch (Incubation)
+Bundle-SymbolicName: org.eclipse.recommenders.snipmatch;singleton:=true
+Bundle-Version: 0.5.1.qualifier
+Bundle-Activator: org.eclipse.recommenders.snipmatch.rcp.SnipMatchPlugin
+Bundle-Vendor: Eclipse Code Recommenders
+Require-Bundle: org.eclipse.ui,
+ org.eclipse.core.runtime,
+ org.eclipse.jface.text,
+ org.eclipse.jdt.core,
+ org.eclipse.core.resources,
+ org.eclipse.jdt.ui,
+ org.apache.commons.httpclient;bundle-version="3.1.0",
+ org.apache.lucene,
+ com.google.guava;bundle-version="10.0.0",
+ org.eclipse.recommenders.utils
+Bundle-RequiredExecutionEnvironment: JavaSE-1.6
+Bundle-ActivationPolicy: lazy
+Bundle-ClassPath: .
+Import-Package: org.eclipse.core.expressions,
+ org.eclipse.ui.internal.texteditor.quickdiff,
+ org.eclipse.ui.texteditor
+Export-Package: org.eclipse.recommenders.snipmatch.core,
+ org.eclipse.recommenders.snipmatch.rcp
diff --git a/plugins/org.eclipse.recommenders.snipmatch.rcp/plugin.xml b/plugins/org.eclipse.recommenders.snipmatch.rcp/plugin.xml
index 8bd4cca..6e64671 100644
--- a/plugins/org.eclipse.recommenders.snipmatch.rcp/plugin.xml
+++ b/plugins/org.eclipse.recommenders.snipmatch.rcp/plugin.xml
@@ -169,6 +169,27 @@
</description>
</fontDefinition>
</extension>
+<extension
+ point="org.eclipse.ui.preferencePages">
+ <page
+ class="org.eclipse.recommenders.snipmatch.preferences.SnipMatchPreferencePage"
+ id="org.eclipse.recommenders.snipmatch.preferences.SnipMatchPreferencePage"
+ category="org.eclipse.recommenders.rcp.category.preferences"
+ name="SnipMatch">
+ </page>
+ <page
+ class="org.eclipse.recommenders.snipmatch.preferences.GitRepositorySettingPreferencePage"
+ id="org.eclipse.recommenders.snipmatch.preferences.SnipMatchGeneralPreferencePage"
+ category="org.eclipse.recommenders.snipmatch.preferences.SnipMatchPreferencePage"
+ name="Local setting">
+ </page>
+ </extension>
+ <extension
+ point="org.eclipse.core.runtime.preferences">
+ <initializer
+ class="org.eclipse.recommenders.snipmatch.preferences.PreferenceInitializer">
+ </initializer>
+ </extension>
<extension
point="org.eclipse.ui.menus">
<menuContribution
diff --git a/plugins/org.eclipse.recommenders.snipmatch.rcp/src/org/eclipse/recommenders/snipmatch/preferences/GitRepositorySettingPreferencePage.java b/plugins/org.eclipse.recommenders.snipmatch.rcp/src/org/eclipse/recommenders/snipmatch/preferences/GitRepositorySettingPreferencePage.java
new file mode 100644
index 0000000..76d493c
--- /dev/null
+++ b/plugins/org.eclipse.recommenders.snipmatch.rcp/src/org/eclipse/recommenders/snipmatch/preferences/GitRepositorySettingPreferencePage.java
@@ -0,0 +1,92 @@
+/**
+ * Copyright (c) 2011 Doug Wightman, Zi Ye, Cheng Chen
+ * 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
+ *
+ * Contributors:
+ * Cheng Chen - initial API and implementation.
+ */
+
+package org.eclipse.recommenders.snipmatch.preferences;
+
+import org.eclipse.jface.preference.DirectoryFieldEditor;
+import org.eclipse.jface.preference.FileFieldEditor;
+import org.eclipse.jface.preference.PreferencePage;
+import org.eclipse.recommenders.snipmatch.rcp.SnipMatchPlugin;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.ui.IWorkbench;
+import org.eclipse.ui.IWorkbenchPreferencePage;
+
+/**
+ * SnipMatch local setting preference page.
+ */
+public class GitRepositorySettingPreferencePage extends PreferencePage implements IWorkbenchPreferencePage {
+
+ private DirectoryFieldEditor snippetsDir = null;
+ private FileFieldEditor snippetsIndexFile = null;
+ private Button updateIndexButton = null;
+
+ public GitRepositorySettingPreferencePage() {
+ super();
+ setPreferenceStore(SnipMatchPlugin.getDefault().getPreferenceStore());
+ }
+
+ protected Control createContents(Composite parent) {
+ Composite storeSettingGroup = new Composite(parent, SWT.LEFT);
+ storeSettingGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+ storeSettingGroup.setLayout(new GridLayout());
+
+ snippetsDir = new DirectoryFieldEditor(PreferenceConstants.SNIPPETS_STORE_DIR, "&Snippets directory:",
+ storeSettingGroup);
+ snippetsDir.setPreferencePage(this);
+ snippetsDir.setPreferenceStore(getPreferenceStore());
+ snippetsDir.load();
+
+ snippetsIndexFile = new FileFieldEditor(PreferenceConstants.SNIPPETS_INDEX_FILE, "&Search engine file path:",
+ storeSettingGroup);
+ snippetsIndexFile.setPreferencePage(this);
+ snippetsIndexFile.setPreferenceStore(getPreferenceStore());
+ snippetsIndexFile.load();
+
+ updateIndexButton = new Button(storeSettingGroup, SWT.NONE);
+ updateIndexButton.setText(" Update index ");
+
+ updateIndexButton.addSelectionListener(new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent evt) {
+ performOk();
+ SnipMatchPlugin.getDefault().getSearchEngine().updateIndex();
+ }
+ });
+
+ return storeSettingGroup;
+ }
+
+ public void dispose() {
+ super.dispose();
+ }
+
+ protected void performDefaults() {
+ this.snippetsDir.loadDefault();
+ this.snippetsIndexFile.loadDefault();
+ super.performDefaults();
+ }
+
+ public boolean performOk() {
+ this.snippetsDir.store();
+ this.snippetsIndexFile.store();
+ return true;
+ }
+
+ public void init(IWorkbench workbench) {
+ }
+
+}
diff --git a/plugins/org.eclipse.recommenders.snipmatch.rcp/src/org/eclipse/recommenders/snipmatch/preferences/PreferenceConstants.java b/plugins/org.eclipse.recommenders.snipmatch.rcp/src/org/eclipse/recommenders/snipmatch/preferences/PreferenceConstants.java
new file mode 100644
index 0000000..b3ae00c
--- /dev/null
+++ b/plugins/org.eclipse.recommenders.snipmatch.rcp/src/org/eclipse/recommenders/snipmatch/preferences/PreferenceConstants.java
@@ -0,0 +1,20 @@
+package org.eclipse.recommenders.snipmatch.preferences;
+
+/**
+ * Constant definitions for plug-in preferences
+ */
+public class PreferenceConstants {
+ public static final String SEARCH_MODEL = "searchModel";
+
+ public static final String SEARCH_MODEL_LOCAL = "local";
+
+ public static final String SEARCH_MODEL_REMOTE = "remote";
+
+ public static final String SEARCH_MODEL_MIXED = "mixed";
+
+ public static final String SNIPPETS_DIR_USE_DEFAULT = "snippetsUseDefault";
+
+ public static final String SNIPPETS_STORE_DIR = "snippetsStoreDir";
+
+ public static final String SNIPPETS_INDEX_FILE = "snippetsIndexDir";
+}
diff --git a/plugins/org.eclipse.recommenders.snipmatch.rcp/src/org/eclipse/recommenders/snipmatch/preferences/PreferenceInitializer.java b/plugins/org.eclipse.recommenders.snipmatch.rcp/src/org/eclipse/recommenders/snipmatch/preferences/PreferenceInitializer.java
new file mode 100644
index 0000000..ef21767
--- /dev/null
+++ b/plugins/org.eclipse.recommenders.snipmatch.rcp/src/org/eclipse/recommenders/snipmatch/preferences/PreferenceInitializer.java
@@ -0,0 +1,49 @@
+/**
+ * Copyright (c) 2011 Doug Wightman, Zi Ye, Cheng Chen
+ * 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
+ *
+ * Contributors:
+ * Cheng Chen - initial API and implementation.
+ */
+package org.eclipse.recommenders.snipmatch.preferences;
+
+import java.io.File;
+
+import org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer;
+import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.recommenders.snipmatch.rcp.SnipMatchPlugin;
+
+/**
+ * Class used to initialize default preference values.
+ */
+public class PreferenceInitializer extends AbstractPreferenceInitializer {
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer#initializeDefaultPreferences()
+ */
+ public void initializeDefaultPreferences() {
+ IPreferenceStore store = SnipMatchPlugin.getDefault().getPreferenceStore();
+ String defaultPath = System.getProperty("user.home");
+ File snipmatchDefaultPath = new File(defaultPath, "/.eclipse/recommenders/snippets/");
+ if (!snipmatchDefaultPath.exists() || !snipmatchDefaultPath.isDirectory()) {
+ boolean success = snipmatchDefaultPath.mkdirs();
+ if (success) {
+ defaultPath = snipmatchDefaultPath.getAbsolutePath();
+ }
+ } else
+ defaultPath = snipmatchDefaultPath.getAbsolutePath();
+
+ store.setDefault(PreferenceConstants.SEARCH_MODEL, PreferenceConstants.SEARCH_MODEL_LOCAL);
+
+ store.setDefault(PreferenceConstants.SNIPPETS_STORE_DIR, defaultPath);
+ store.setDefault(PreferenceConstants.SNIPPETS_INDEX_FILE,
+ new File(defaultPath, "simpleIndex.txt").getAbsolutePath());
+ store.setDefault(PreferenceConstants.SNIPPETS_DIR_USE_DEFAULT, true);
+ }
+
+}
diff --git a/plugins/org.eclipse.recommenders.snipmatch.rcp/src/org/eclipse/recommenders/snipmatch/preferences/SnipMatchPreferencePage.java b/plugins/org.eclipse.recommenders.snipmatch.rcp/src/org/eclipse/recommenders/snipmatch/preferences/SnipMatchPreferencePage.java
new file mode 100644
index 0000000..f088067
--- /dev/null
+++ b/plugins/org.eclipse.recommenders.snipmatch.rcp/src/org/eclipse/recommenders/snipmatch/preferences/SnipMatchPreferencePage.java
@@ -0,0 +1,43 @@
+package org.eclipse.recommenders.snipmatch.preferences;
+
+import org.eclipse.jface.preference.FieldEditorPreferencePage;
+import org.eclipse.recommenders.snipmatch.rcp.SnipMatchPlugin;
+import org.eclipse.ui.IWorkbench;
+import org.eclipse.ui.IWorkbenchPreferencePage;
+
+/**
+ * This class represents a preference page that is used to set up whether to use
+ * local search engine or remote search engine .
+ * <p>
+ * This page is used to modify preferences only. They are stored in the
+ * preference store that belongs to the main plug-in class. That way,
+ * preferences can be accessed directly via the preference store.
+ */
+
+public class SnipMatchPreferencePage extends FieldEditorPreferencePage implements IWorkbenchPreferencePage {
+
+ public SnipMatchPreferencePage() {
+ super(GRID);
+ setPreferenceStore(SnipMatchPlugin.getDefault().getPreferenceStore());
+ setDescription("Setting pages for Recommenders SnipMatch");
+ }
+
+ /**
+ * Creates the local search engine & remote search engine selection
+ * checkbox.
+ */
+ public void createFieldEditors() {
+
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.eclipse.ui.IWorkbenchPreferencePage#init(org.eclipse.ui.IWorkbench)
+ */
+ public void init(IWorkbench workbench) {
+
+ }
+
+} \ No newline at end of file