| 1 | package org.axdt.axdoc.preferences; |
|---|
| 2 | |
|---|
| 3 | import org.axdt.axdoc.AXDocPlugin; |
|---|
| 4 | import org.axdt.axdoc.model.AXLevel; |
|---|
| 5 | import org.axdt.axdoc.model.AXRoot; |
|---|
| 6 | import org.axdt.axdoc.model.AXRootType; |
|---|
| 7 | import org.axdt.axdoc.preferences.DocTableFieldEditor.DocItem; |
|---|
| 8 | import org.axdt.axdoc.util.Index0r; |
|---|
| 9 | import org.axdt.preferences.AbstractPreferences; |
|---|
| 10 | import org.eclipse.jface.preference.IPreferenceStore; |
|---|
| 11 | |
|---|
| 12 | public class AXDocPreferences extends AbstractPreferences { |
|---|
| 13 | |
|---|
| 14 | public final static String LANGREF_PATH = "LANGREF_PATH"; |
|---|
| 15 | private static AXDocPreferences instance; |
|---|
| 16 | |
|---|
| 17 | public static AXDocPreferences getInstance() { |
|---|
| 18 | if (instance == null) new AXDocPreferences(); |
|---|
| 19 | return instance; |
|---|
| 20 | } |
|---|
| 21 | |
|---|
| 22 | public AXDocPreferences() { |
|---|
| 23 | super("Preferences for asdoc support"); |
|---|
| 24 | instance = this; |
|---|
| 25 | } |
|---|
| 26 | |
|---|
| 27 | @Override |
|---|
| 28 | public String getQualifier() { |
|---|
| 29 | return AXDocPlugin.PLUGIN_ID; |
|---|
| 30 | } |
|---|
| 31 | |
|---|
| 32 | @Override |
|---|
| 33 | public void initializeFieldSpecs() { |
|---|
| 34 | add(new DocTableField(LANGREF_PATH, "Asdoc uris", "file:/home/mb0/workspace/axdt/org.axdt.axdoc.test/data/asdoc")); |
|---|
| 35 | } |
|---|
| 36 | |
|---|
| 37 | public static String getLangRefPathString() { |
|---|
| 38 | IPreferenceStore store = getInstance().getStore(); |
|---|
| 39 | return store.getString(LANGREF_PATH); |
|---|
| 40 | } |
|---|
| 41 | public static void checkAXDocPaths(Index0r index0r) { |
|---|
| 42 | String string = getLangRefPathString(); |
|---|
| 43 | Object[] values = DocTableFieldEditor.deserializeValue(string); |
|---|
| 44 | for (Object value:values) { |
|---|
| 45 | if (value instanceof DocItem) { |
|---|
| 46 | DocItem item = (DocItem) value; |
|---|
| 47 | AXRoot root = index0r.addRoot(item.name, item.url, AXRootType.ASDOC); |
|---|
| 48 | index0r.initialize(root, AXLevel.TYPE); |
|---|
| 49 | } |
|---|
| 50 | } |
|---|
| 51 | } |
|---|
| 52 | @Override |
|---|
| 53 | public void initializeDefaultPreferences() { |
|---|
| 54 | super.initializeDefaultPreferences(); |
|---|
| 55 | } |
|---|
| 56 | } |
|---|