Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Add output printing on R scripts sourcing

The normal R behavior is reproduced.
  • Loading branch information...
commit 16e98b7881ae712369e97b4ce13e22e6e4880469 1 parent bf59949
valyo valyo authored
4 plugins/net.bioclipse.r.business/src/net/bioclipse/r/business/IRBusinessManager.java
@@ -56,9 +56,9 @@
56 56
57 57 @Recorded
58 58 @PublishedMethod(
59   - methodSummary = "Passes source(filepath) to eval"
  59 + methodSummary = "Changes the file separator in filepath to /"
60 60 )
61   - public String source(String filepath);
  61 + public String fixFilepath(String filepath);
62 62
63 63 @Recorded
64 64 @PublishedMethod(
6 plugins/net.bioclipse.r.business/src/net/bioclipse/r/business/RBusinessManager.java
@@ -467,9 +467,9 @@ public String evalSnippet(String seltext) {
467 467 return cmd;
468 468 }
469 469
470   - public String source(String filepath) {
471   - eval("source(\"" + filepath.replace(fileseparator, "/") + "\")");
472   - return "";
  470 + public String fixFilepath(String filepath) {
  471 + filepath = filepath.replace(fileseparator, "/");
  472 + return filepath;
473 473 }
474 474
475 475 public String ls() {
2  plugins/net.bioclipse.r.ui/src/net/bioclipse/r/ui/handlers/RunRAllHandler.java
@@ -35,7 +35,7 @@ public Object execute(ExecutionEvent event) throws ExecutionException {
35 35 System.out.println("Editor content: \n" + contents);
36 36
37 37 RConsoleView rView = (RConsoleView) PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().findView("net.bioclipse.r.ui.views.RConsoleView");
38   - rView.execSnippet(contents);
  38 + rView.execEditorInpit(contents);
39 39 //We are done
40 40 return null;
41 41 }
9 plugins/net.bioclipse.r.ui/src/net/bioclipse/r/ui/handlers/RunRScriptHandler.java
@@ -3,6 +3,7 @@
3 3 import net.bioclipse.r.business.Activator;
4 4 import net.bioclipse.r.business.IRBusinessManager;
5 5 import net.bioclipse.r.ui.editors.REditor;
  6 +import net.bioclipse.r.ui.views.RConsoleView;
6 7
7 8 import org.eclipse.core.commands.AbstractHandler;
8 9 import org.eclipse.core.commands.ExecutionEvent;
@@ -31,9 +32,13 @@ public Object execute(ExecutionEvent event) throws ExecutionException {
31 32 String filepath = reditor.getFilePath();
32 33 System.out.println("File path is: " + filepath);
33 34
34   - //Pass the path to RBusinessManager
  35 + //Get the file path with correct file separator
35 36 IRBusinessManager r = Activator.getDefault().getJavaRBusinessManager();
36   - r.source(filepath);
  37 + filepath = r.fixFilepath(filepath);
  38 +
  39 + //Pass the path to the R console method
  40 + RConsoleView rView = (RConsoleView) PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().findView("net.bioclipse.r.ui.views.RConsoleView");
  41 + rView.execEditorInpit("source(\"" + filepath + "\")");
37 42
38 43 //We are done
39 44 return null;
2  plugins/net.bioclipse.r.ui/src/net/bioclipse/r/ui/handlers/RunRSnippetHandler.java
@@ -29,7 +29,7 @@ public Object execute(ExecutionEvent event) throws ExecutionException {
29 29 System.out.println("You selected text: \n" + textsel.getText());
30 30
31 31 RConsoleView rView = (RConsoleView) PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().findView("net.bioclipse.r.ui.views.RConsoleView");
32   - rView.execSnippet(textsel.getText());
  32 + rView.execEditorInpit(textsel.getText());
33 33 //We are done
34 34 return null;
35 35 }
4 plugins/net.bioclipse.r.ui/src/net/bioclipse/r/ui/views/RConsoleView.java
@@ -30,6 +30,8 @@ public RConsoleView() {
30 30 public void createPartControl(Composite parent) {
31 31 super.createPartControl(parent);
32 32 getRBusinessManager();
  33 + if (r == null)
  34 + getRBusinessManager();
33 35 if (!r.getRightRVersion()){
34 36 getSite().getShell().getDisplay().asyncExec
35 37 (new Runnable() {
@@ -41,7 +43,7 @@ public void run() {
41 43
42 44 }
43 45
44   - public String execSnippet(String command) {
  46 + public String execEditorInpit(String command) {
45 47 return executeCommand(command);
46 48 }
47 49 /*

0 comments on commit 16e98b7

Please sign in to comment.
Something went wrong with that request. Please try again.