Skip to content

Commit

Permalink
Add output printing on R scripts sourcing
Browse files Browse the repository at this point in the history
The normal R behavior is reproduced.
  • Loading branch information
Valentin Georgiev committed Feb 22, 2012
1 parent bf59949 commit 16e98b7
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 10 deletions.
Expand Up @@ -56,9 +56,9 @@ public interface IRBusinessManager extends IBioclipseManager {

@Recorded
@PublishedMethod(
methodSummary = "Passes source(filepath) to eval"
methodSummary = "Changes the file separator in filepath to /"
)
public String source(String filepath);
public String fixFilepath(String filepath);

@Recorded
@PublishedMethod(
Expand Down
Expand Up @@ -467,9 +467,9 @@ public String[] parseCommand(String command) {
return cmd;
}

public String source(String filepath) {
eval("source(\"" + filepath.replace(fileseparator, "/") + "\")");
return "";
public String fixFilepath(String filepath) {
filepath = filepath.replace(fileseparator, "/");
return filepath;
}

public String ls() {
Expand Down
Expand Up @@ -35,7 +35,7 @@ public Object execute(ExecutionEvent event) throws ExecutionException {
System.out.println("Editor content: \n" + contents);

RConsoleView rView = (RConsoleView) PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().findView("net.bioclipse.r.ui.views.RConsoleView");
rView.execSnippet(contents);
rView.execEditorInpit(contents);
//We are done
return null;
}
Expand Down
Expand Up @@ -3,6 +3,7 @@
import net.bioclipse.r.business.Activator;
import net.bioclipse.r.business.IRBusinessManager;
import net.bioclipse.r.ui.editors.REditor;
import net.bioclipse.r.ui.views.RConsoleView;

import org.eclipse.core.commands.AbstractHandler;
import org.eclipse.core.commands.ExecutionEvent;
Expand Down Expand Up @@ -31,9 +32,13 @@ public Object execute(ExecutionEvent event) throws ExecutionException {
String filepath = reditor.getFilePath();
System.out.println("File path is: " + filepath);

//Pass the path to RBusinessManager
//Get the file path with correct file separator
IRBusinessManager r = Activator.getDefault().getJavaRBusinessManager();
r.source(filepath);
filepath = r.fixFilepath(filepath);

//Pass the path to the R console method
RConsoleView rView = (RConsoleView) PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().findView("net.bioclipse.r.ui.views.RConsoleView");
rView.execEditorInpit("source(\"" + filepath + "\")");

//We are done
return null;
Expand Down
Expand Up @@ -29,7 +29,7 @@ public Object execute(ExecutionEvent event) throws ExecutionException {
System.out.println("You selected text: \n" + textsel.getText());

RConsoleView rView = (RConsoleView) PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().findView("net.bioclipse.r.ui.views.RConsoleView");
rView.execSnippet(textsel.getText());
rView.execEditorInpit(textsel.getText());
//We are done
return null;
}
Expand Down
Expand Up @@ -30,6 +30,8 @@ public RConsoleView() {
public void createPartControl(Composite parent) {
super.createPartControl(parent);
getRBusinessManager();
if (r == null)
getRBusinessManager();
if (!r.getRightRVersion()){
getSite().getShell().getDisplay().asyncExec
(new Runnable() {
Expand All @@ -41,7 +43,7 @@ public void run() {

}

public String execSnippet(String command) {
public String execEditorInpit(String command) {
return executeCommand(command);
}
/*
Expand Down

0 comments on commit 16e98b7

Please sign in to comment.