Ticket #13: patch.txt

File patch.txt, 7.1 KB (added by maccaf, 5 years ago)
Line 
1Index: /home/lneterda/workspace2/net.sourceforge.eclipsetrader.core/plugin.xml
2===================================================================
3--- /home/lneterda/workspace2/net.sourceforge.eclipsetrader.core/plugin.xml (revision 525)
4+++ /home/lneterda/workspace2/net.sourceforge.eclipsetrader.core/plugin.xml (working copy)
5@@ -8,6 +8,7 @@
6    <extension-point id="loggingPreferences" name="Logging Preferences" schema="schema/loggingPreferences.exsd"/>
7    <extension-point id="tradingProviders" name="Trading Providers" schema="schema/tradingProviders.exsd"/>
8    <extension-point id="viewLabelProviders" name="View Label Providers" schema="schema/viewLabelProviders.exsd"/>
9+   <extension-point id="customRepository" name="Custom Repository" schema="schema/customRepository.exsd"/>
10    <extension
11          point="org.eclipse.ui.actionSets">
12       <actionSet
13Index: /home/lneterda/workspace2/net.sourceforge.eclipsetrader.core/schema/customRepository.exsd
14===================================================================
15--- /home/lneterda/workspace2/net.sourceforge.eclipsetrader.core/schema/customRepository.exsd   (revision 0)
16+++ /home/lneterda/workspace2/net.sourceforge.eclipsetrader.core/schema/customRepository.exsd   (revision 0)
17@@ -0,0 +1,112 @@
18+<?xml version='1.0' encoding='UTF-8'?>
19+<!-- Schema file written by PDE -->
20+<schema targetNamespace="net.sourceforge.eclipsetrader.core">
21+<annotation>
22+      <appInfo>
23+         <meta.schema plugin="net.sourceforge.eclipsetrader.core" id="customRepository" name="Custom Repository"/>
24+      </appInfo>
25+      <documentation>
26+         [Enter description of this extension point.]
27+      </documentation>
28+   </annotation>
29+
30+   <element name="extension">
31+      <complexType>
32+         <sequence>
33+            <element ref="repository"/>
34+         </sequence>
35+         <attribute name="point" type="string" use="required">
36+            <annotation>
37+               <documentation>
38+                 
39+               </documentation>
40+            </annotation>
41+         </attribute>
42+         <attribute name="id" type="string">
43+            <annotation>
44+               <documentation>
45+                 
46+               </documentation>
47+            </annotation>
48+         </attribute>
49+         <attribute name="name" type="string">
50+            <annotation>
51+               <documentation>
52+                 
53+               </documentation>
54+               <appInfo>
55+                  <meta.attribute translatable="true"/>
56+               </appInfo>
57+            </annotation>
58+         </attribute>
59+      </complexType>
60+   </element>
61+
62+   <element name="repository">
63+      <complexType>
64+         <attribute name="name" type="string" use="required">
65+            <annotation>
66+               <documentation>
67+                 
68+               </documentation>
69+            </annotation>
70+         </attribute>
71+         <attribute name="value" type="string" use="required">
72+            <annotation>
73+               <documentation>
74+                 
75+               </documentation>
76+               <appInfo>
77+                  <meta.attribute kind="java" basedOn="net.sourceforge.eclipsetrader.core.Repository"/>
78+               </appInfo>
79+            </annotation>
80+         </attribute>
81+      </complexType>
82+   </element>
83+
84+   <annotation>
85+      <appInfo>
86+         <meta.section type="since"/>
87+      </appInfo>
88+      <documentation>
89+         [Enter the first release in which this extension point appears.]
90+      </documentation>
91+   </annotation>
92+
93+   <annotation>
94+      <appInfo>
95+         <meta.section type="examples"/>
96+      </appInfo>
97+      <documentation>
98+         [Enter extension point usage example here.]
99+      </documentation>
100+   </annotation>
101+
102+   <annotation>
103+      <appInfo>
104+         <meta.section type="apiInfo"/>
105+      </appInfo>
106+      <documentation>
107+         [Enter API information here.]
108+      </documentation>
109+   </annotation>
110+
111+   <annotation>
112+      <appInfo>
113+         <meta.section type="implementation"/>
114+      </appInfo>
115+      <documentation>
116+         [Enter information about supplied implementation of this extension point.]
117+      </documentation>
118+   </annotation>
119+
120+   <annotation>
121+      <appInfo>
122+         <meta.section type="copyright"/>
123+      </appInfo>
124+      <documentation>
125+         
126+      </documentation>
127+   </annotation>
128+
129+</schema>
130Index: /home/lneterda/workspace2/net.sourceforge.eclipsetrader.core/src/net/sourceforge/eclipsetrader/core/CorePlugin.java
131===================================================================
132--- /home/lneterda/workspace2/net.sourceforge.eclipsetrader.core/src/net/sourceforge/eclipsetrader/core/CorePlugin.java (revision 525)
133+++ /home/lneterda/workspace2/net.sourceforge.eclipsetrader.core/src/net/sourceforge/eclipsetrader/core/CorePlugin.java (working copy)
134@@ -61,6 +61,7 @@
135     public static final String ACCOUNT_PROVIDERS_EXTENSION_POINT = PLUGIN_ID + ".accountProviders"; //$NON-NLS-1$
136     public static final String LABEL_PROVIDERS_EXTENSION_POINT = PLUGIN_ID + ".viewLabelProviders"; //$NON-NLS-1$
137     public static final String LOGGER_PREFERENCES_EXTENSION_POINT = PLUGIN_ID + ".loggingPreferences"; //$NON-NLS-1$
138+   public static final String REPOSITORY_PREFERENCES_EXTENSION_POINT = PLUGIN_ID + ".customRepository"; //$NON-NLS-1$
139     public static final String FEED_RUNNING = "FEED_RUNNING"; //$NON-NLS-1$
140     public static final String PREFS_ENABLE_HTTP_PROXY = "ENABLE_HTTP_PROXY"; //$NON-NLS-1$
141     public static final String PREFS_PROXY_HOST_ADDRESS = "PROXY_HOST_ADDRESS"; //$NON-NLS-1$
142@@ -241,22 +242,40 @@
143         return plugin;
144     }
145 
146-    public static Repository getRepository()
147-    {
148-        if (repository == null)
149-        {
150-            try
151-            {
152-                Class clazz = Class.forName("net.sourceforge.eclipsetrader.core.RepositoryImpl");
153-                repository = (Repository)clazz.newInstance();
154-            }
155-            catch (Exception e)
156-            {
157-                repository = new XMLRepository();
158-            }
159-        }
160-        return repository;
161-    }
162+   public static Repository getRepository() {
163+       if (repository == null) {
164+           IExtensionRegistry registry = Platform.getExtensionRegistry();
165+           IExtensionPoint extensionPoint = registry
166+                   .getExtensionPoint(CorePlugin.REPOSITORY_PREFERENCES_EXTENSION_POINT);
167+           IConfigurationElement[] members = extensionPoint
168+                   .getConfigurationElements();
169+           if (members.length > 0) {
170+               IConfigurationElement element = members[0];
171+               if (element.getName().equals("repository")) {
172+                   if (element.getAttribute("value") != null) {
173+                       try {
174+                           Object ooo = element
175+                                   .createExecutableExtension("value");
176+                           repository = (Repository) ooo;
177+                       } catch (Exception e) {
178+                           repository = new XMLRepository();
179+                       }
180+                   }
181+               }
182+           }
183+
184+           if (repository == null) {
185+               try {
186+                   Class clazz = Class
187+                           .forName("net.sourceforge.eclipsetrader.core.RepositoryImpl");
188+                   repository = (Repository) clazz.newInstance();
189+               } catch (Exception e) {
190+                   repository = new XMLRepository();
191+               }
192+           }
193+       }
194+       return repository;
195+   }
196 
197     /**
198      * Returns an image descriptor for the image file at the given