Skip to content

Commit 2f91eb9

Browse files
author
Paul Verest 风行华中
committed
option to have completions.json as external file
1 parent 88ff13f commit 2f91eb9

File tree

4 files changed

+34
-2
lines changed

4 files changed

+34
-2
lines changed

org.nodeclipse.ui/src/org/nodeclipse/ui/contentassist/ContentProvider.java

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,24 @@
88
import org.json.JSONException;
99
import org.json.JSONObject;
1010
import org.nodeclipse.ui.util.Constants;
11+
import org.nodeclipse.ui.util.ProcessUtils;
1112

13+
/**
14+
* @author LambGao
15+
* @author Paul Verest
16+
*/
1217
public class ContentProvider {
1318

1419
public static JSONArray COMPLETIONS;
1520

1621
static {
1722
try {
18-
//TODO option to have this as external file
19-
InputStream is = ContentProvider.class.getClassLoader().getResourceAsStream(Constants.COMPLETIONS_JSON);
23+
// option to have completions.json as external file
24+
String completionJsonPath = ProcessUtils.getCompletionsJsonPath();
25+
if (completionJsonPath == null || completionJsonPath.equals("")) {
26+
completionJsonPath = Constants.COMPLETIONS_JSON;
27+
}
28+
InputStream is = ContentProvider.class.getClassLoader().getResourceAsStream(completionJsonPath);
2029
JSONObject object = new JSONObject(inputStream2String(is));
2130
COMPLETIONS = object.getJSONArray(Constants.COMPLETIONS_KEY);
2231
} catch (JSONException e) {

org.nodeclipse.ui/src/org/nodeclipse/ui/preferences/NodePreferencePage.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,15 @@
66
import org.eclipse.ui.IWorkbenchPreferencePage;
77
import org.nodeclipse.ui.Activator;
88

9+
/**
10+
* @author Tomoyuki Inagaki
11+
* @author Paul Verest
12+
*/
913
public class NodePreferencePage extends FieldEditorPreferencePage implements IWorkbenchPreferencePage {
1014

1115
private FileFieldEditor fileFieldEditor;
1216
private FileFieldEditor expressPath;
17+
private FileFieldEditor completionsPath;
1318

1419
public NodePreferencePage() {
1520
super(GRID);
@@ -29,6 +34,9 @@ protected void createFieldEditors() {
2934

3035
expressPath = new FileFieldEditor(PreferenceConstants.EXPRESS_PATH, "Express Path:", getFieldEditorParent());
3136
addField(expressPath);
37+
38+
completionsPath = new FileFieldEditor(PreferenceConstants.COMPLETIONS_JSON_PATH, "Completions.json Path:", getFieldEditorParent());
39+
addField(completionsPath);
3240
}
3341

3442
@Override

org.nodeclipse.ui/src/org/nodeclipse/ui/preferences/PreferenceConstants.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,15 @@
22

33
/**
44
* Constant definitions for plug-in preferences
5+
*
6+
* @author Tomoyuki Inagaki
7+
* @author Paul Verest
58
*/
69
public class PreferenceConstants {
710

811
public static final String NODE_PATH = "node_path";
912
public static final String EXPRESS_PATH = "express_pass";
1013
public static final String EXPRESS_VERSION = "express_version";
14+
public static final String COMPLETIONS_JSON_PATH = "completionsjson_path";
1115

1216
}

org.nodeclipse.ui/src/org/nodeclipse/ui/util/ProcessUtils.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,11 @@
1010
import org.nodeclipse.ui.Activator;
1111
import org.nodeclipse.ui.preferences.PreferenceConstants;
1212

13+
/**
14+
* @author ?
15+
* @author Tomoyuki Inagaki
16+
* @author Paul Verest
17+
*/
1318
public class ProcessUtils {
1419
public static String getNodePath() {
1520
return Activator.getDefault().getPreferenceStore()
@@ -42,6 +47,12 @@ public static String getExpressVersion() {
4247
return Activator.getDefault().getPreferenceStore()
4348
.getString(PreferenceConstants.EXPRESS_VERSION);
4449
}
50+
51+
public static String getCompletionsJsonPath() {
52+
return Activator.getDefault().getPreferenceStore()
53+
.getString(PreferenceConstants.COMPLETIONS_JSON_PATH);
54+
}
55+
4556

4657
public static int getExpressMajorVersion() {
4758
String ver = getExpressVersion();

0 commit comments

Comments
 (0)