Skip to content

Commit

Permalink
Improve the R console output
Browse files Browse the repository at this point in the history
from executing snippets/R editor content
  • Loading branch information
Valentin Georgiev committed Jan 4, 2012
1 parent 3fd6919 commit 671e7bb
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 24 deletions.
Expand Up @@ -21,6 +21,7 @@
import java.io.StringWriter;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.ArrayList;
import java.util.NoSuchElementException;

import javax.security.auth.login.LoginException;
Expand All @@ -39,9 +40,6 @@
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
import org.eclipse.ui.PartInitException;
import org.eclipse.ui.PlatformUI;

import de.walware.rj.data.RObject;
import de.walware.rj.data.RStore;
import de.walware.rj.servi.RServi;
Expand All @@ -57,6 +55,7 @@ public class RBusinessManager implements IBioclipseManager {
private static final String OS = System.getProperty("os.name").toString();
private RServiManager rsmanager = new RServiManager("Rconsole");
public static String NEWLINE = System.getProperty("line.separator");
public static String cmdparser = "(;?\r?\n|;)";
public static final String fileseparator = java.io.File.separator;

public RBusinessManager() throws LoginException, NoSuchElementException {
Expand Down Expand Up @@ -433,13 +432,6 @@ else if (command.contains("quartz"))
}

public String evalSnippet(String seltext) {
try {
PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().showView("net.bioclipse.r.ui.views.RConsoleView");
} catch (PartInitException e) {
// TODO Auto-generated catch block
e.printStackTrace();
logger.debug(e);
}
String retVal = null;
String[] commands = parseCommand(seltext);
for (String cmd : commands) {
Expand All @@ -450,16 +442,12 @@ public String evalSnippet(String seltext) {
}

public String[] parseCommand(String command) {
StringBuilder cmdbuild = new StringBuilder();
String[] lines = command.split("\n");
for (String line : lines) {
if (!line.startsWith("#") && line.length() != 0) {
cmdbuild.append(line);
cmdbuild.append(";");
}
}
String lncmd = cmdbuild.toString();
String[] cmd = lncmd.split(";");
String[] cmd = command.split(cmdparser);
ArrayList<String> list = new ArrayList<String>();
for (String s : cmd)
if (!s.startsWith("#") && s.length() != 0)
list.add(s);
cmd = list.toArray(new String[list.size()]);
return cmd;
}

Expand Down
Expand Up @@ -34,8 +34,6 @@ public Object execute(ExecutionEvent event) throws ExecutionException {

System.out.println("Editor content: \n" + contents);

IRBusinessManager r = Activator.getDefault().getJavaRBusinessManager();
r.evalSnippet(contents);
RConsoleView rView = (RConsoleView) PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().findView("net.bioclipse.r.ui.views.RConsoleView");
rView.execSnippet(contents);
//We are done
Expand Down
Expand Up @@ -30,8 +30,6 @@ public Object execute(ExecutionEvent event) throws ExecutionException {
ITextSelection textsel = (ITextSelection) selection;
System.out.println("You selected text: \n" + textsel.getText());

IRBusinessManager r = Activator.getDefault().getJavaRBusinessManager();
r.evalSnippet(textsel.getText());
RConsoleView rView = (RConsoleView) PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().findView("net.bioclipse.r.ui.views.RConsoleView");
rView.execSnippet(textsel.getText());
//We are done
Expand Down

0 comments on commit 671e7bb

Please sign in to comment.