Révision 1955

tmp/org.txm.statsengine.r.core/schema/org.txm.statengine.r.core.RTransformer.exsd (revision 1955)
1
<?xml version='1.0' encoding='UTF-8'?>
2
<!-- Schema file written by PDE -->
3
<schema targetNamespace="org.txm.statsengine.r.core" xmlns="http://www.w3.org/2001/XMLSchema">
4
<annotation>
5
      <appinfo>
6
         <meta.schema plugin="org.txm.statsengine.r.core" id="org.txm.statengine.r.core.RTransformer" name="org.txm.statengine.r.core.RTransformer"/>
7
      </appinfo>
8
      <documentation>
9
         A transformer allow to import data in the RWorkspace or to export a R data to a TXM object
10
      </documentation>
11
   </annotation>
12

  
13
   <element name="extension">
14
      <annotation>
15
         <appinfo>
16
            <meta.element />
17
         </appinfo>
18
      </annotation>
19
      <complexType>
20
         <choice minOccurs="1" maxOccurs="unbounded">
21
            <element ref="transformer"/>
22
         </choice>
23
         <attribute name="point" type="string" use="required">
24
            <annotation>
25
               <documentation>
26
                  
27
               </documentation>
28
            </annotation>
29
         </attribute>
30
         <attribute name="id" type="string">
31
            <annotation>
32
               <documentation>
33
                  
34
               </documentation>
35
            </annotation>
36
         </attribute>
37
         <attribute name="name" type="string">
38
            <annotation>
39
               <documentation>
40
                  
41
               </documentation>
42
               <appinfo>
43
                  <meta.attribute translatable="true"/>
44
               </appinfo>
45
            </annotation>
46
         </attribute>
47
      </complexType>
48
   </element>
49

  
50
   <element name="transformer">
51
      <complexType>
52
         <attribute name="class" type="string" use="required">
53
            <annotation>
54
               <documentation>
55
                  
56
               </documentation>
57
               <appinfo>
58
                  <meta.attribute kind="java" basedOn="org.txm.statsengine.r.core.RTransformer"/>
59
               </appinfo>
60
            </annotation>
61
         </attribute>
62
         <attribute name="type" type="string" use="required">
63
            <annotation>
64
               <documentation>
65
                  The TXMResult managed by the transformer
66
               </documentation>
67
               <appinfo>
68
                  <meta.attribute kind="java" basedOn="org.txm.core.results.TXMResult:"/>
69
               </appinfo>
70
            </annotation>
71
         </attribute>
72
      </complexType>
73
   </element>
74

  
75
   <annotation>
76
      <appinfo>
77
         <meta.section type="since"/>
78
      </appinfo>
79
      <documentation>
80
         [Enter the first release in which this extension point appears.]
81
      </documentation>
82
   </annotation>
83

  
84
   <annotation>
85
      <appinfo>
86
         <meta.section type="examples"/>
87
      </appinfo>
88
      <documentation>
89
         [Enter extension point usage example here.]
90
      </documentation>
91
   </annotation>
92

  
93
   <annotation>
94
      <appinfo>
95
         <meta.section type="apiinfo"/>
96
      </appinfo>
97
      <documentation>
98
         [Enter API information here.]
99
      </documentation>
100
   </annotation>
101

  
102
   <annotation>
103
      <appinfo>
104
         <meta.section type="implementation"/>
105
      </appinfo>
106
      <documentation>
107
         [Enter information about supplied implementation of this extension point.]
108
      </documentation>
109
   </annotation>
110

  
111

  
112
</schema>
0 113

  
tmp/org.txm.statsengine.r.core/src/org/txm/statsengine/r/core/RTransformer.java (revision 1955)
1
package org.txm.statsengine.r.core;
2

  
3
import org.txm.core.results.TXMResult;
4
import org.txm.statsengine.r.core.exceptions.RWorkspaceException;
5

  
6
/**
7
 * a RTransformer allows to transfert data from TXM/R to R/TXM
8
 * 
9
 * RTransformer are registered in the RStatengine and used by the SendToR command
10
 * 
11
 * @author mdecorde
12
 *
13
 * @param <T>
14
 */
15
public abstract class RTransformer<T extends TXMResult> {
16
	
17
	/**
18
	 * 
19
	 * @param symbol the R symbol pointing to the R variable to transfert in TXM (Java part)
20
	 * @return the resulting TXMResult
21
	 * @throws RWorkspaceException
22
	 */
23
	public abstract T fromRtoTXM(String symbol) throws RWorkspaceException;
24
	
25
	/**
26
	 * 
27
	 * @param o the result to tranfert in R
28
	 * @return the created R variable symbol
29
	 * @throws RWorkspaceException
30
	 */
31
	public abstract String fromTXMtoR(TXMResult o) throws RWorkspaceException;
32
}
0 33

  
tmp/org.txm.statsengine.r.core/src/org/txm/statsengine/r/core/RStatsEngine.java (revision 1955)
1 1
package org.txm.statsengine.r.core;
2 2

  
3
import java.util.HashMap;
4

  
5
import org.eclipse.core.runtime.IConfigurationElement;
3 6
import org.eclipse.core.runtime.IProgressMonitor;
7
import org.eclipse.core.runtime.RegistryFactory;
8
import org.txm.core.messages.TXMCoreMessages;
9
import org.txm.core.results.TXMResult;
4 10
import org.txm.statsengine.core.StatsEngine;
5 11
import org.txm.statsengine.r.core.exceptions.RWorkspaceException;
6 12
import org.txm.statsengine.r.core.messages.RCoreMessages;
......
78 84
			RWorkspace.setUseFileCommunication(RPreferences.getInstance().getBoolean(RPreferences.FILE_TRANSFERT));
79 85
			//	System.out.println("success");
80 86
			//System.out.println("file transfert ? "+RWorkspace.isFileTranfert());
87
			
88
			loadRTransformers();
81 89
		} catch (RWorkspaceException e) {
82 90
			Log.severe(RCoreMessages.error_connectionFailed); 
83 91
			started = false;
......
86 94
		return started;
87 95
	}
88 96

  
89
	
97
	public HashMap<String, RTransformer<? extends TXMResult>> getTransformers() {
98
		return transformers;
99
	}
90 100

  
101
	HashMap<String, RTransformer<? extends TXMResult>> transformers = new HashMap<String, RTransformer<? extends TXMResult>>();
102
	private void loadRTransformers() {
103
		
104
		transformers.clear();
105
		IConfigurationElement[] contributions = RegistryFactory.getRegistry().getConfigurationElementsFor(RTransformer.class.getName());
91 106

  
107
		Log.finest(TXMCoreMessages.bind("Looking for R transformers contributions with extension point id {1}...", RTransformer.class.getName())); //$NON-NLS-1$
108
		Log.finest(TXMCoreMessages.bind("{0} transformers(s) found.", contributions.length)); //$NON-NLS-1$
109

  
110
		for (int i = 0; i < contributions.length; i++) {
111
			try {
112
				@SuppressWarnings("unchecked")
113
				RTransformer<? extends TXMResult> transformer = (RTransformer<? extends TXMResult>) contributions[i].createExecutableExtension("class"); //$NON-NLS-1$
114

  
115
				Log.fine(TXMCoreMessages.bind("Registering R transformer: {0}...", transformer));
116

  
117
				transformers.put(contributions[i].getAttribute("type"), transformer);
118
			} catch (Exception e) {
119
				Log.severe("Error: failed to instantiate " + contributions[i].getName() + ".");
120
				e.printStackTrace();
121
			}
122
		}
123
	}
124

  
92 125
	@Override
93 126
	public boolean stop() {
94 127
		try {
128
			transformers.clear();
95 129
			RWorkspace.shutdown();
96 130
			RStatsEngine.kill();
97 131
			started = false;
......
218 252
	public String getName() {
219 253
		return "R";
220 254
	}
221
	
222 255
}
tmp/org.txm.statsengine.r.core/plugin.xml (revision 1955)
1 1
<?xml version="1.0" encoding="UTF-8"?>
2 2
<?eclipse version="3.4"?>
3 3
<plugin>
4
   <extension-point id="org.txm.statengine.r.core.RTransformer" name="org.txm.statengine.r.core.RTransformer" schema="schema/org.txm.statengine.r.core.RTransformer.exsd"/>
4 5
   <extension
5 6
         point="org.eclipse.core.runtime.preferences">
6 7
      <initializer

Formats disponibles : Unified diff