Révision 2506
| tmp/org.txm.statsengine.r.core/src/org/txm/statsengine/r/core/preferences/RPreferences.java (revision 2506) | ||
|---|---|---|
| 19 | 19 |
* |
| 20 | 20 |
*/ |
| 21 | 21 |
public class RPreferences extends TXMPreferences {
|
| 22 |
|
|
| 23 |
|
|
| 22 |
|
|
| 23 |
|
|
| 24 | 24 |
public static final String PREFERENCES_PREFIX = "r_"; //$NON-NLS-1$ |
| 25 | 25 |
|
| 26 | 26 |
/** The Constant R_REMOTE. */ |
| 27 | 27 |
public static final String IS_MANDATORY = PREFERENCES_PREFIX + "is_mandatory"; //$NON-NLS-1$ |
| 28 |
|
|
| 28 |
|
|
| 29 | 29 |
/** The Constant R_PATH_TO_EXECUTABLE. */ |
| 30 | 30 |
public static final String PATH_TO_EXECUTABLE = PREFERENCES_PREFIX + "path_to_executable"; //$NON-NLS-1$ |
| 31 |
|
|
| 31 |
|
|
| 32 | 32 |
/** The Constant R_REMOTE. */ |
| 33 | 33 |
public static final String REMOTE = PREFERENCES_PREFIX + "remote"; //$NON-NLS-1$ |
| 34 |
|
|
| 34 | 35 |
public static final String DEBUG = PREFERENCES_PREFIX + "debug"; //$NON-NLS-1$ |
| 35 |
|
|
| 36 |
|
|
| 36 | 37 |
/** The Constant R_SERVER_ADDRESS. */ |
| 37 | 38 |
public static final String SERVER_ADDRESS = PREFERENCES_PREFIX + "server_address"; //$NON-NLS-1$ |
| 38 |
|
|
| 39 |
|
|
| 39 | 40 |
/** The Constant R_PORT. */ |
| 40 | 41 |
public static final String PORT = PREFERENCES_PREFIX + "port"; //$NON-NLS-1$ |
| 41 |
|
|
| 42 |
|
|
| 42 | 43 |
/** The Constant R_USER. */ |
| 43 | 44 |
public static final String USER = PREFERENCES_PREFIX + "user"; //$NON-NLS-1$ |
| 44 |
|
|
| 45 |
|
|
| 45 | 46 |
/** The Constant R_PASSWORD. */ |
| 46 | 47 |
public static final String PASSWORD = PREFERENCES_PREFIX + "password"; //$NON-NLS-1$ |
| 47 |
|
|
| 48 |
|
|
| 48 | 49 |
// FIXME: SJ: not used anymore? |
| 49 | 50 |
/** The Constant R_PACKAGES_PATH. */ |
| 50 | 51 |
public static final String PACKAGES_PATH = PREFERENCES_PREFIX + "packages_path"; //$NON-NLS-1$ |
| 51 |
|
|
| 52 |
|
|
| 52 | 53 |
public static final String RARGS = PREFERENCES_PREFIX + "rargs"; //$NON-NLS-1$ |
| 54 |
|
|
| 53 | 55 |
public static final String RSERVEARGS = PREFERENCES_PREFIX + "rserveargs"; //$NON-NLS-1$ |
| 54 |
|
|
| 56 |
|
|
| 55 | 57 |
/** The Constant R_DISABLE. */ |
| 56 | 58 |
public static final String DISABLE = PREFERENCES_PREFIX + "disable"; //$NON-NLS-1$ |
| 57 |
|
|
| 59 |
|
|
| 58 | 60 |
/** The Constant R_FILE_TRANSFERT. */ |
| 59 | 61 |
public static final String FILE_TRANSFERT = PREFERENCES_PREFIX + "file_transfert"; //$NON-NLS-1$ |
| 62 |
|
|
| 60 | 63 |
public static final String SVG_DEVICE = PREFERENCES_PREFIX + "svg_device"; //$NON-NLS-1$ |
| 61 |
|
|
| 62 |
/** Last version since R Preferences have been set -> the setting is done only ONE time.*/ |
|
| 64 |
|
|
| 65 |
/** Last version since R Preferences have been set -> the setting is done only ONE time. */
|
|
| 63 | 66 |
public static final String VERSION = "version"; //$NON-NLS-1$ |
| 64 |
|
|
| 67 |
|
|
| 65 | 68 |
/** |
| 66 | 69 |
* To show or not not the R eval command lines. |
| 67 | 70 |
*/ |
| 68 | 71 |
public static final String SHOW_EVAL_LOGS = "show_eval_logs"; //$NON-NLS-1$ |
| 69 | 72 |
|
| 70 |
|
|
| 71 | 73 |
|
| 72 | 74 |
/** |
| 75 |
* Gets the instance. |
|
| 73 | 76 |
* |
| 77 |
* @return the instance |
|
| 74 | 78 |
*/ |
| 75 |
public RPreferences() {
|
|
| 76 |
// TODO Auto-generated constructor stub |
|
| 79 |
public static TXMPreferences getInstance() {
|
|
| 80 |
if (!TXMPreferences.instances.containsKey(RPreferences.class)) {
|
|
| 81 |
new RPreferences(); |
|
| 82 |
} |
|
| 83 |
return TXMPreferences.instances.get(RPreferences.class); |
|
| 77 | 84 |
} |
| 78 |
|
|
| 85 |
|
|
| 86 |
|
|
| 87 |
|
|
| 79 | 88 |
@Override |
| 80 | 89 |
public void initializeDefaultPreferences() {
|
| 81 | 90 |
super.initializeDefaultPreferences(); |
| 82 | 91 |
|
| 83 | 92 |
|
| 84 | 93 |
// FIXME: SJ: some code in this method should be done only at TXM first run |
| 85 |
|
|
| 86 | 94 |
|
| 95 |
|
|
| 87 | 96 |
Preferences preferences = this.getDefaultPreferencesNode(); |
| 88 |
|
|
| 97 |
|
|
| 89 | 98 |
preferences.putBoolean(IS_MANDATORY, false); |
| 90 | 99 |
preferences.put(SERVER_ADDRESS, "127.0.0.1"); |
| 91 | 100 |
preferences.putBoolean(REMOTE, false); |
| ... | ... | |
| 100 | 109 |
preferences.put(SVG_DEVICE, "svg"); |
| 101 | 110 |
preferences.putBoolean(SHOW_EVAL_LOGS, false); |
| 102 | 111 |
|
| 103 |
String RFRAGMENT = "org.txm.statsengine.r.core."+System.getProperty("osgi.os"); //$NON-NLS-1$
|
|
| 112 |
String RFRAGMENT = "org.txm.statsengine.r.core." + System.getProperty("osgi.os"); //$NON-NLS-1$
|
|
| 104 | 113 |
|
| 105 | 114 |
Log.fine("RPreferences.initializeDefaultPreferences()");
|
| 106 | 115 |
|
| 107 | 116 |
String saved = getString(RPreferences.VERSION); |
| 108 | 117 |
Version currentVersion = BundleUtils.getBundleVersion(RFRAGMENT); // the RFRAGMENT plugin contains the right version |
| 109 | 118 |
|
| 110 |
//ensure plugin binary files rights are ok |
|
| 119 |
// ensure plugin binary files rights are ok
|
|
| 111 | 120 |
String os = ""; //$NON-NLS-1$ |
| 112 | 121 |
String ext = ""; //$NON-NLS-1$ |
| 113 | 122 |
String osName = System.getProperty("os.name").toLowerCase(); //$NON-NLS-1$
|
| ... | ... | |
| 116 | 125 |
os = "win32"; //$NON-NLS-1$ |
| 117 | 126 |
extraSubPath = "x64/"; |
| 118 | 127 |
ext = ".exe"; //$NON-NLS-1$ |
| 119 |
} else if (osName.contains("mac")) { //$NON-NLS-1$
|
|
| 128 |
} |
|
| 129 |
else if (osName.contains("mac")) { //$NON-NLS-1$
|
|
| 120 | 130 |
os = "macosx"; //$NON-NLS-1$ |
| 121 |
} else {
|
|
| 131 |
} |
|
| 132 |
else {
|
|
| 122 | 133 |
os = "linux32"; //$NON-NLS-1$ |
| 123 |
if (System.getProperty("os.arch").contains("64")) //$NON-NLS-1$ //$NON-NLS-2$
|
|
| 134 |
if (System.getProperty("os.arch").contains("64")) //$NON-NLS-1$ //$NON-NLS-2$
|
|
| 124 | 135 |
os = "linux64"; //$NON-NLS-1$ |
| 125 | 136 |
} |
| 126 |
|
|
| 137 |
|
|
| 127 | 138 |
File bundleDir = BundleUtils.getBundleFile(RFRAGMENT); |
| 128 | 139 |
if (bundleDir == null) {
|
| 129 | 140 |
Log.severe(TXMCoreMessages.bind("Error while retrieving {0} bundle directory.", RFRAGMENT));
|
| ... | ... | |
| 134 | 145 |
File execFile = new File(OSDir, "bin/" + extraSubPath + "R" + ext); //$NON-NLS-1$ //$NON-NLS-2$ |
| 135 | 146 |
execFile.setExecutable(true); |
| 136 | 147 |
|
| 137 |
|
|
| 148 |
|
|
| 138 | 149 |
if (!osName.contains("windows")) { //$NON-NLS-1$
|
| 139 | 150 |
try {
|
| 140 | 151 |
Log.fine(TXMCoreMessages.bind("Setting execution file rights to: {0}.", OSDir.getAbsolutePath()));
|
| 141 |
Process p = Runtime.getRuntime().exec("chmod -R +x "+OSDir.getAbsolutePath()); //$NON-NLS-1$
|
|
| 152 |
Process p = Runtime.getRuntime().exec("chmod -R +x " + OSDir.getAbsolutePath()); //$NON-NLS-1$
|
|
| 142 | 153 |
new StreamHog(p.getInputStream(), false); |
| 143 | 154 |
new StreamHog(p.getErrorStream(), false); |
| 144 | 155 |
p.waitFor(); |
| 145 |
} catch (Exception e) {
|
|
| 156 |
} |
|
| 157 |
catch (Exception e) {
|
|
| 146 | 158 |
Log.severe(TXMCoreMessages.bind("Error while setting execution file rights to: {0}.", OSDir.getAbsolutePath()));
|
| 147 | 159 |
e.printStackTrace(); |
| 148 | 160 |
return; |
| 149 | 161 |
} |
| 150 | 162 |
} |
| 151 |
|
|
| 163 |
|
|
| 152 | 164 |
if (!execFile.exists()) {
|
| 153 | 165 |
Log.severe(TXMCoreMessages.bind("Can not find R executable file: {0}.", execFile));
|
| 154 | 166 |
return; |
| ... | ... | |
| 161 | 173 |
|
| 162 | 174 |
preferences.put(PATH_TO_EXECUTABLE, execFile.getAbsolutePath()); |
| 163 | 175 |
|
| 164 |
|
|
| 176 |
|
|
| 165 | 177 |
if (saved != null && saved.length() > 0) {
|
| 166 | 178 |
Version savedVersion = new Version(saved); |
| 167 | 179 |
if (currentVersion.compareTo(savedVersion) <= 0) {
|
| ... | ... | |
| 193 | 205 |
Log.fine(TXMCoreMessages.bind("R stats engine preferences set with: {0} and {1}.", OSDir.getAbsolutePath(), execFile.getAbsolutePath())); //$NON-NLS-1$
|
| 194 | 206 |
} |
| 195 | 207 |
|
| 196 |
/** |
|
| 197 |
* Gets the instance. |
|
| 198 |
* @return the instance |
|
| 199 |
*/ |
|
| 200 |
public static TXMPreferences getInstance() {
|
|
| 201 |
if (!TXMPreferences.instances.containsKey(RPreferences.class)) {
|
|
| 202 |
new RPreferences(); |
|
| 203 |
} |
|
| 204 |
return TXMPreferences.instances.get(RPreferences.class); |
|
| 205 |
} |
|
| 206 | 208 |
} |
| tmp/org.txm.statsengine.r.core/src/org/txm/statsengine/r/core/messages/messages.properties (revision 2506) | ||
|---|---|---|
| 1 |
#TXM messages generated by the PluginMessagesManager class |
|
| 2 |
#Tue Dec 18 10:24:08 CET 2018 |
|
| 3 |
doneColon=Done in {0} ms.
|
|
| 4 |
error_cantFindRServeInPath=** The statistics engine program path is set ({0}) but we couldn''t find it.
|
|
| 5 |
error_connectionFailed=** Error while connecting to the statistics engine. |
|
| 6 |
error_errorDuringItemsListExtraction=** Error while retrieving the list of items \: \t |
|
| 7 |
error_errorWhileEvaluating=** R error\: "{0}"\nwhile evaluating\: {1}
|
|
| 8 |
error_evaluationError=** Evaluation error\: {0}\n{1}.
|
|
| 9 |
error_failedToConnectToTheRWorkspace=** Failed to connect to the R Workspace with {0}, {1} and {2}.
|
|
| 10 |
error_failedToInitializeFileTransfert=** Failed to initialize file transfer\: {0}.
|
|
| 11 |
error_failedToLoadLibrary=** Failed to load the {0} library\: {1}.
|
|
| 12 |
error_failedToRunREG=** Failed to run REG to locate the R program. |
|
| 13 |
error_failedToStartRServe=** Failed to start the statistics engine (RServe). |
|
| 14 |
error_failedToStartRServeWithCommand=** Failed to start Rserve with command\: |
|
| 15 |
error_matrixIsEmpty=Matrix is empty. |
|
| 16 |
error_requestedObjectNotFoundInR=The requested object ({0}) was not found in the R workspace.
|
|
| 17 |
error_rserveIsAlreadyRunningOnPort=** Rserve is already running on port {0}.
|
|
| 18 |
error_rservePathNotSet=** The statistics engine program path is not set and we could not find it. |
|
| 19 |
error_unexpectedErrorInRStatisticsEngine=** Unexpected error in R statistics engine\: {0}.
|
|
| 20 |
error_youNeedRSoftware=You need the 'R' software and you need to configure its access paths via the preferences window 'Tools / Preferences'. |
|
| 21 |
errorWhileRunningRScriptP0ColonP1=** Error while running R script {0}\: {1}.
|
|
| 22 |
info_connectingToRAt=Connecting to R at address {0}\:{1}.
|
|
| 23 |
info_connectingToRAtWithUser=Connecting to R at address {0}\:{1} with user {2}.
|
|
| 24 |
info_lastSafeEvalExpression=Last safeeval expression\: {0}.
|
|
| 25 |
info_rPathNotSetTryingToFindIt=R executable file path not specified, searching it in standard locations... |
|
| 26 |
info_savingChartToFile=Saving chart to file\: {0}.
|
|
| 27 |
info_startingRWithCommandLine=Starting R with command line\: {0}
|
|
| 28 |
info_startingStatsEngine=Starting statistics engine\: user \= {0}, remote \= {1}, port \= {2}, debug \= {3}.
|
|
| 29 |
info_statisticsEngineLaunched=Statistical engine launched. |
|
| 30 |
info_tryingToStartRFrom=Trying to start R from {0}…
|
|
| 31 |
info_tryingToStartRWithRPath=Trying to start R from path 'R'. |
|
| 32 |
p0RScriptDoesntExist=** The R script file {0} doesn''t exist.
|
|
| 33 |
runningP0=Running {0}…
|
|
| 34 |
runningTextSelection=Running text selection… |
|
| 35 |
rserveNotStartedUsingTheP0Path=** Error: Rserve not started using the {0} path.
|
|
| 1 |
#Generated by ResourceBundle Editor (http://essiembre.github.io/eclipse-rbe/) |
|
| 2 |
#TXM messages generated by the PluginMessagesManager class |
|
| 3 |
#Tue Dec 18 10:24:08 CET 2018 |
|
| 4 |
|
|
| 5 |
doneColon = Done in {0} ms.
|
|
| 6 |
|
|
| 7 |
errorWhileRunningRScriptP0ColonP1 = ** Error while running R script {0}: {1}.
|
|
| 8 |
|
|
| 9 |
error_cantFindRServeInPath = ** The statistics engine program path is set ({0}) but we couldn''t find it.
|
|
| 10 |
error_connectionFailed = ** Error while connecting to the statistics engine. |
|
| 11 |
error_errorDuringItemsListExtraction = ** Error while retrieving the list of items : \ |
|
| 12 |
error_errorWhileEvaluating = ** R error: "{0}"\nwhile evaluating: {1}
|
|
| 13 |
error_evaluationError = ** Evaluation error: {0}\n{1}.
|
|
| 14 |
error_failedToConnectToTheRWorkspace = ** Failed to connect to the R Workspace with {0}, {1} and {2}.
|
|
| 15 |
error_failedToInitializeFileTransfert = ** Failed to initialize file transfer: {0}.
|
|
| 16 |
error_failedToLoadLibrary = ** Failed to load the {0} library: {1}.
|
|
| 17 |
error_failedToRunREG = ** Failed to run REG to locate the R program. |
|
| 18 |
error_failedToStartRServe = ** Failed to start the statistics engine (RServe). |
|
| 19 |
error_failedToStartRServeWithCommand = ** Failed to start Rserve with command: |
|
| 20 |
error_matrixIsEmpty = Matrix is empty. |
|
| 21 |
error_requestedObjectNotFoundInR = The requested object ({0}) was not found in the R workspace.
|
|
| 22 |
error_rserveIsAlreadyRunningOnPort = ** Rserve is already running on port {0}.
|
|
| 23 |
error_rservePathNotSet = ** The statistics engine program path is not set and we could not find it. |
|
| 24 |
error_unexpectedErrorInRStatisticsEngine = ** Unexpected error in R statistics engine: {0}.
|
|
| 25 |
error_youNeedRSoftware = You need the 'R' software and you need to configure its access paths via the preferences window 'Tools / Preferences'. |
|
| 26 |
|
|
| 27 |
info_connectingToRAt = Connecting to R at address {0}:{1}.
|
|
| 28 |
info_connectingToRAtWithUser = Connecting to R at address {0}:{1} with user {2}.
|
|
| 29 |
info_lastSafeEvalExpression = Last safeeval expression: {0}.
|
|
| 30 |
info_rPathNotSetTryingToFindIt = R executable file path not specified, searching it in standard locations... |
|
| 31 |
info_savingChartToFile = Saving chart to file: {0}.
|
|
| 32 |
info_startingRWithCommandLine = Starting R with command line: {0}
|
|
| 33 |
info_startingStatsEngine = Starting statistics engine: user = {0}, remote = {1}, port = {2}, debug = {3}.
|
|
| 34 |
info_statisticsEngineLaunched = Statistics engine launched. |
|
| 35 |
info_tryingToStartRFrom = Trying to start R from {0}…
|
|
| 36 |
info_tryingToStartRWithRPath = Trying to start R from path 'R'. |
|
| 37 |
|
|
| 38 |
p0RScriptDoesntExist = ** The R script file {0} doesn''t exist.
|
|
| 39 |
|
|
| 40 |
rserveNotStartedUsingTheP0Path = ** Error: Rserve not started using the {0} path.
|
|
| 41 |
|
|
| 42 |
runningP0 = Running {0}…
|
|
| 43 |
|
|
| 44 |
runningTextSelection = Running text selection… |
|
Formats disponibles : Unified diff