Skip to content

Commit

Permalink
Lots of features :)
Browse files Browse the repository at this point in the history
  • Loading branch information
cande committed May 3, 2011
1 parent bf6a0ec commit bfdf92d
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 13 deletions.
3 changes: 2 additions & 1 deletion plugins/net.bioclipse.r.business/META-INF/MANIFEST.MF
Expand Up @@ -17,5 +17,6 @@ Bundle-RequiredExecutionEnvironment: JavaSE-1.6
Import-Package: de.walware.rj.data,
de.walware.rj.servi,
de.walware.rj.services;version="0.5.0",
org.apache.log4j
org.apache.log4j,
org.eclipse.core.resources
Bundle-ActivationPolicy: lazy
Expand Up @@ -83,7 +83,7 @@ public IJavaScriptRBusinessManager getJavaScriptRBusinessManager() {
IJavaScriptRBusinessManager manager = null;
try {
manager = (IJavaScriptRBusinessManager)
jsFinderTracker.waitForService(1000*10);
jsFinderTracker.waitForService(1000*20);
}
catch (InterruptedException e) {
throw new IllegalStateException(
Expand Down
Expand Up @@ -23,6 +23,10 @@
import de.walware.rj.data.RStore;
import net.bioclipse.r.RServiManager;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.resources.IWorkspaceRoot;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.resources.IWorkspace;

public class RBusinessManager implements IBioclipseManager {

Expand All @@ -45,13 +49,20 @@ public RBusinessManager() throws LoginException, NoSuchElementException {
working = false;
status = e.getMessage();
}
catch (CoreException e) { // Catch R startup errors.
catch (CoreException e) { // Catch rj startup error.
working = false;
status = extractRjError(e.getCause().getCause().getMessage());
}
if (working) {
try { rservi = rsmanager.getRServi("task"); }
catch (CoreException e){
try {
rservi = rsmanager.getRServi("task");
// rservi.evalData("session.save()", null);
IWorkspace workspace = ResourcesPlugin.getWorkspace();
IWorkspaceRoot root = workspace.getRoot();
IPath location = root.getLocation();
logger.debug(location.toString());
}
catch (CoreException e) {
working = false;
status = e.getMessage();
}
Expand Down Expand Up @@ -79,7 +90,7 @@ public String eval(String command) {
logger.debug("R cmd: " + command);
String returnVal;
try {
RObject data = rservi.evalData("capture.output(print(("+command+")))",null); // capture.output(print( )) gives a string output from R, otherwise R objects. The extra pair of () is needed for the R function print to work properly.
RObject data = rservi.evalData("capture.output(print(("+command+")))", null); // capture.output(print( )) gives a string output from R, otherwise R objects. The extra pair of () is needed for the R function print to work properly.
RStore rData = data.getData();
StringBuilder builder = new StringBuilder();
for(int i=0;i<rData.getLength();i++) {
Expand Down
Expand Up @@ -22,21 +22,26 @@ public class RConsoleView extends ScriptingConsoleView {

public RConsoleView() {
logger.info("Starting R console UI");
r = Activator.getDefault().getJavaRBusinessManager();
}

@Override
protected String executeCommand( String command ) {
String returnVal;
echoCommand(command);
String returnVal = "";
if (r == null)
getRBusinessManager();
echoCommand(command);
if (r.isWorking()) {
returnVal = r.eval(command);
returnVal = r.eval(command);
} else
returnVal = "R console is inactivated: " + r.getStatus();
printMessage(returnVal);
printMessage(returnVal);
return returnVal;
}

private void getRBusinessManager() {
r = Activator.getDefault().getJavaRBusinessManager();
}

protected void waitUntilCommandFinished() {
// Don't know if there's a way to sensibly implement this method for R.
}
Expand Down
2 changes: 1 addition & 1 deletion plugins/net.bioclipse.r/src/net/bioclipse/r/Activator.java
Expand Up @@ -50,7 +50,7 @@ public void stop(BundleContext context) throws Exception {

public synchronized RServiManager getRServiManager() {
if (rserviManager == null) {
rserviManager = new RServiManager("RCPDemo");
// rserviManager = new RServiManager("RCPDemo"); // is this needed?
}
return rserviManager;
}
Expand Down
Expand Up @@ -94,7 +94,14 @@ else if (rExist(path + "R.exe"))
path = path.substring(0, path.indexOf("bin\\"));
logger.info("R_HOME path corrected, removed bin\\ from path.");
trustRPath = true;
}
} else if (OS.startsWith("Linux")) {
if (!path.endsWith("/"))
path += "/";
trustRPath = rExist(path + "bin/R");
// link: /usr/bin/R -> /usr/lib/R/bin/R
// no link: /usr/lib/R/R -> /usr/lib/R/bin/R
// R_HOME is /usr/lib/R
}
if (!trustRPath)
throw new FileNotFoundException("Incorrect R_HOME path: " + path);
logger.debug("New path: " + path);
Expand Down

0 comments on commit bfdf92d

Please sign in to comment.