|
From: Markus B. <mba...@us...> - 2005-09-25 16:49:50
|
Update of /cvsroot/rubyeclipse/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/rdocexport In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24985/src/org/rubypeople/rdt/internal/ui/rdocexport Modified Files: RDocUtility.java Log Message: fixed rdoc launch error in linux, use RubyInterpreter.exec for launching the interpreter for rdoc, externalized messages Index: RDocUtility.java =================================================================== RCS file: /cvsroot/rubyeclipse/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/rdocexport/RDocUtility.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** RDocUtility.java 19 Sep 2005 21:46:49 -0000 1.2 --- RDocUtility.java 25 Sep 2005 16:49:42 -0000 1.3 *************** *** 3,19 **** import java.io.BufferedReader; import java.io.File; - import java.io.IOException; import java.io.InputStreamReader; import java.util.HashSet; import java.util.Iterator; import java.util.Set; import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.IResource; import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.Path; import org.eclipse.jface.dialogs.ErrorDialog; import org.rubypeople.rdt.internal.launching.RubyRuntime; import org.rubypeople.rdt.internal.ui.RubyPlugin; import org.rubypeople.rdt.internal.ui.dialogs.StatusInfo; import org.rubypeople.rdt.ui.PreferenceConstants; --- 3,25 ---- import java.io.BufferedReader; import java.io.File; import java.io.InputStreamReader; + import java.util.ArrayList; import java.util.HashSet; import java.util.Iterator; + import java.util.List; import java.util.Set; import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.IResource; + import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.Path; import org.eclipse.jface.dialogs.ErrorDialog; + import org.eclipse.jface.dialogs.MessageDialog; + import org.rubypeople.rdt.internal.launching.RdtLaunchingMessages; + import org.rubypeople.rdt.internal.launching.RubyInterpreter; import org.rubypeople.rdt.internal.launching.RubyRuntime; import org.rubypeople.rdt.internal.ui.RubyPlugin; + import org.rubypeople.rdt.internal.ui.RubyUIMessages; import org.rubypeople.rdt.internal.ui.dialogs.StatusInfo; import org.rubypeople.rdt.ui.PreferenceConstants; *************** *** 29,33 **** private static Set listeners = new HashSet(); ! private static boolean isDebug = false ; public static void addRdocListener(RdocListener listener) { --- 35,39 ---- private static Set listeners = new HashSet(); ! private static boolean isDebug = false; public static void addRdocListener(RdocListener listener) { *************** *** 38,46 **** listeners.remove(listener); } ! public static void setDebugging(boolean isDebug) { ! RDocUtility.isDebug = isDebug ; } ! public static void generateDocumentation(IResource resource) { RubyInvoker invoker = new RubyInvoker(resource); --- 44,52 ---- listeners.remove(listener); } ! public static void setDebugging(boolean isDebug) { ! RDocUtility.isDebug = isDebug; } ! public static void generateDocumentation(IResource resource) { RubyInvoker invoker = new RubyInvoker(resource); *************** *** 62,70 **** while (!isProject(project)) { project = project.getParent(); ! if (project == null) ! break; } ! if (project != null && isProject(project)) ! this.resource = project; } --- 68,74 ---- while (!isProject(project)) { project = project.getParent(); ! if (project == null) break; } ! if (project != null && isProject(project)) this.resource = project; } *************** *** 73,83 **** } - protected String getArgString() { - return " -r " + resource.getLocation().toOSString(); - } - private void log(String message) { if (RDocUtility.isDebug) { ! System.out.println(message) ; } } --- 77,83 ---- } private void log(String message) { if (RDocUtility.isDebug) { ! System.out.println(message); } } *************** *** 85,93 **** public final void invoke() { log("Generating RDoc for " + resource.getName()); ! IPath rubyPath = RubyRuntime.getDefault().getSelectedInterpreter() ! .getInstallLocation(); ! IPath rdocPath = new Path(RubyPlugin.getDefault() ! .getPreferenceStore().getString( ! PreferenceConstants.RDOC_PATH)); // check the rdoc path for existence. It might have been --- 85,97 ---- public final void invoke() { log("Generating RDoc for " + resource.getName()); ! ! RdtLaunchingMessages.getString("RdtLaunchingPlugin.noInterpreterSelected"); ! RubyInterpreter interpreter = RubyRuntime.getDefault().getSelectedInterpreter(); ! if (interpreter == null) { ! MessageDialog.openInformation(RubyPlugin.getActiveWorkbenchShell(), RdtLaunchingMessages.getString("RdtLaunchingPlugin.noInterpreterSelectedTitle"), RdtLaunchingMessages.getString("RdtLaunchingPlugin.noInterpreterSelected")); ! return ; ! } ! ! IPath rdocPath = new Path(RubyPlugin.getDefault().getPreferenceStore().getString(PreferenceConstants.RDOC_PATH)); // check the rdoc path for existence. It might have been *************** *** 98,119 **** // If we can't find it ourselves then display an error to the user if (!file.exists() || !file.isFile()) { ! // TODO Extract the displayed strings to a properties file ! String message = "The input path for RDoc is blank or incorrect."; ! ErrorDialog.openError(RubyPlugin.getActiveWorkbenchShell(), ! "Rdoc location incorrect", message, new StatusInfo( ! StatusInfo.ERROR, message)); return; } ! String riCmd = "\"" + rubyPath + "\" \"" + rdocPath.toString() + "\""; ! String call = riCmd + getArgString(); try { ! log(call); ! final Process p = Runtime.getRuntime().exec(call); ! handleOutput(p, call); ! } catch (IOException e) { RubyPlugin.log(e); log(e.getMessage()); ! ErrorDialog.openError(RubyPlugin.getActiveWorkbenchShell(), "Error running Rdoc", e.getMessage(), new StatusInfo(StatusInfo.ERROR, e.getMessage())); } } --- 102,120 ---- // If we can't find it ourselves then display an error to the user if (!file.exists() || !file.isFile()) { ! MessageDialog.openError(RubyPlugin.getActiveWorkbenchShell(), RubyUIMessages.getString("RDocPathErrorTitle"), RubyUIMessages.getString("RDocPathError")) ; return; } ! List args = new ArrayList(); ! args.add(rdocPath.toString()); ! args.add("-r"); ! args.add(resource.getLocation().toOSString()); try { ! final Process p = interpreter.exec(args, null); ! handleOutput(p, args); ! } catch (CoreException e) { RubyPlugin.log(e); log(e.getMessage()); ! ErrorDialog.openError(RubyPlugin.getActiveWorkbenchShell(), RubyUIMessages.getString("ErrorRunningRdocTitle"), e.getMessage(), new StatusInfo(StatusInfo.ERROR, e.getMessage())); } } *************** *** 127,133 **** * The Process. */ ! private void handleOutput(Process p, String cmdLine) { BufferedReader reader = null; ! String lastLine = null ; try { reader = new BufferedReader(new InputStreamReader(p.getErrorStream())); --- 128,134 ---- * The Process. */ ! private void handleOutput(Process p, List cmdLine) { BufferedReader reader = null; ! String lastLine = null; try { reader = new BufferedReader(new InputStreamReader(p.getErrorStream())); *************** *** 135,139 **** while ((line = reader.readLine()) != null) { log(line); ! lastLine = line ; } } catch (Exception e) { --- 136,140 ---- while ((line = reader.readLine()) != null) { log(line); ! lastLine = line; } } catch (Exception e) { *************** *** 143,158 **** p.waitFor(); if (p.exitValue() != 0) { ! String message = "Ruby running rdoc exited abnormally. A possble reason is a wrong Rdoc path. Please check the path for rdoc in the preference page."; ! String additionalMessage = null ; if (lastLine != null) { ! additionalMessage = "The process was started with: "+ cmdLine + ". The last line of stderr of the ruby process: " + lastLine ; ! } ! else { ! additionalMessage = "The process was started with: "+ cmdLine + ". The process did not write any messages to stderr." ; } ! ErrorDialog.openError( RubyPlugin.getActiveWorkbenchShell(), "Ruby process exited with value " + p.exitValue(), message, new StatusInfo(StatusInfo.ERROR, additionalMessage)); } } catch (InterruptedException e) { ! log("InterruptedException while waiting for rdoc process to finish." + e.getMessage()) ; } log("Done generating RDoc"); --- 144,159 ---- p.waitFor(); if (p.exitValue() != 0) { ! String message = RubyUIMessages.getFormattedString("RDocExecutionError", Integer.toString(p.exitValue())) ; ! String additionalMessage = null; if (lastLine != null) { ! additionalMessage = RubyUIMessages.getFormattedString("RDocExecutionErrorAdditionalMessageWithStderr", new String[] { cmdLine.toString(), lastLine }); ! } else { ! additionalMessage = RubyUIMessages.getFormattedString("RDocExecutionErrorAdditionalMessage", cmdLine.toString()); } ! String title = RubyUIMessages.getFormattedString("RDocExecutionErrorTitle", Integer.toString(p.exitValue())) ; ! ErrorDialog.openError(RubyPlugin.getActiveWorkbenchShell(), title, message, new StatusInfo(StatusInfo.ERROR, additionalMessage)); } } catch (InterruptedException e) { ! log("InterruptedException while waiting for rdoc process to finish." + e.getMessage()); } log("Done generating RDoc"); *************** *** 162,166 **** /** * Notify registered listeners that the rdoc has changed ! * */ public static void notifyListeners() { --- 163,167 ---- /** * Notify registered listeners that the rdoc has changed ! * */ public static void notifyListeners() { |