Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorrescobar2011-01-26 22:27:05 +0000
committerRyan D. Brooks2011-01-26 22:27:05 +0000
commitc65a5ff05637db67d103fbd8430a28cfbbfbec04 (patch)
tree1a7060d91b560a37f044bee1dbc32a38b197ed57
parentf7e6f9d0bdcac3abf991aa8b92ac30a803eb19a3 (diff)
downloadorg.eclipse.osee-c65a5ff05637db67d103fbd8430a28cfbbfbec04.tar.gz
org.eclipse.osee-c65a5ff05637db67d103fbd8430a28cfbbfbec04.tar.xz
org.eclipse.osee-c65a5ff05637db67d103fbd8430a28cfbbfbec04.zip
bug: Fix VbaWordDiffGenerator launch and error logging0.9.8.v201101261529_RC
-rw-r--r--plugins/org.eclipse.osee.framework.jdk.core/src/org/eclipse/osee/framework/jdk/core/util/io/streams/StreamCatcher.java1
-rw-r--r--plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/render/WordCompareTest.java81
-rw-r--r--plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/util/VbaWordDiffGenerator.java65
3 files changed, 102 insertions, 45 deletions
diff --git a/plugins/org.eclipse.osee.framework.jdk.core/src/org/eclipse/osee/framework/jdk/core/util/io/streams/StreamCatcher.java b/plugins/org.eclipse.osee.framework.jdk.core/src/org/eclipse/osee/framework/jdk/core/util/io/streams/StreamCatcher.java
index 160f3a4af9..2b789b48b1 100644
--- a/plugins/org.eclipse.osee.framework.jdk.core/src/org/eclipse/osee/framework/jdk/core/util/io/streams/StreamCatcher.java
+++ b/plugins/org.eclipse.osee.framework.jdk.core/src/org/eclipse/osee/framework/jdk/core/util/io/streams/StreamCatcher.java
@@ -20,6 +20,7 @@ import java.util.logging.Logger;
/**
* @author Jeff C. Phillips
*/
+@Deprecated
public class StreamCatcher extends Thread {
private final InputStream is;
private final String type;
diff --git a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/render/WordCompareTest.java b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/render/WordCompareTest.java
index 002ecb49d6..fc50a91461 100644
--- a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/render/WordCompareTest.java
+++ b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/render/WordCompareTest.java
@@ -17,7 +17,6 @@ import java.security.CodeSource;
import java.security.ProtectionDomain;
import javax.swing.JFileChooser;
import javax.swing.filechooser.FileFilter;
-import org.eclipse.osee.framework.jdk.core.util.io.streams.StreamCatcher;
/**
* @author Donald G. Dunne
@@ -102,45 +101,45 @@ public class WordCompareTest {
return toReturn;
}
- public static void main(String[] args) {
-
- try {
- String diffPath = System.getProperty("user.home") + File.separator + "DiffResults";
- File baseFile = getFile("Select Base Xml File To Compare");
- if (!baseFile.exists()) {
- throw new IllegalStateException("baseFile doesn't exist => " + baseFile);
- }
-
- File newerFile = getFile("Select Newer Xml File To Compare");
- if (!newerFile.exists()) {
- throw new IllegalStateException("newerFile doesn't exist => " + newerFile);
- }
-
- File vbDiffScript = getFileSystemPath("support" + File.separator + "compareDocs.vbs");
- if (!vbDiffScript.exists()) {
- throw new IllegalStateException("vbDiffScript doesn't exist => " + vbDiffScript);
- }
-
- // quotes are neccessary because of Runtime.exec wraps the last element in quotes...crazy
- String cmd[] =
- {
- "cmd",
- "/s /c",
- "\"" + vbDiffScript.getPath() + "\"",
- "/author:CoolOseeUser\" /diffPath:\"" + diffPath + "\" /detectFormatChanges:true /ver1:\"" + baseFile.getAbsolutePath() + "\" /ver2:\"" + newerFile.getAbsolutePath()};
-
- Process proc = Runtime.getRuntime().exec(cmd);
-
- StreamCatcher errorCatcher = new StreamCatcher(proc.getErrorStream(), "ERROR");
- StreamCatcher outputCatcher = new StreamCatcher(proc.getInputStream(), "OUTPUT");
-
- errorCatcher.start();
- outputCatcher.start();
- proc.waitFor();
- } catch (Exception ex) {
- ex.printStackTrace();
- }
-
- }
+ // public static void main(String[] args) {
+ //
+ // try {
+ // String diffPath = System.getProperty("user.home") + File.separator + "DiffResults";
+ // File baseFile = getFile("Select Base Xml File To Compare");
+ // if (!baseFile.exists()) {
+ // throw new IllegalStateException("baseFile doesn't exist => " + baseFile);
+ // }
+ //
+ // File newerFile = getFile("Select Newer Xml File To Compare");
+ // if (!newerFile.exists()) {
+ // throw new IllegalStateException("newerFile doesn't exist => " + newerFile);
+ // }
+ //
+ // File vbDiffScript = getFileSystemPath("support" + File.separator + "compareDocs.vbs");
+ // if (!vbDiffScript.exists()) {
+ // throw new IllegalStateException("vbDiffScript doesn't exist => " + vbDiffScript);
+ // }
+ //
+ // // quotes are neccessary because of Runtime.exec wraps the last element in quotes...crazy
+ // String cmd[] =
+ // {
+ // "cmd",
+ // "/s /c",
+ // "\"" + vbDiffScript.getPath() + "\"",
+ // "/author:CoolOseeUser\" /diffPath:\"" + diffPath + "\" /detectFormatChanges:true /ver1:\"" + baseFile.getAbsolutePath() + "\" /ver2:\"" + newerFile.getAbsolutePath()};
+ //
+ // Process proc = Runtime.getRuntime().exec(cmd);
+ //
+ // StreamCatcher errorCatcher = new StreamCatcher(proc.getErrorStream(), "ERROR");
+ // StreamCatcher outputCatcher = new StreamCatcher(proc.getInputStream(), "OUTPUT");
+ //
+ // errorCatcher.start();
+ // outputCatcher.start();
+ // proc.waitFor();
+ // } catch (Exception ex) {
+ // ex.printStackTrace();
+ // }
+ //
+ // }
}
diff --git a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/util/VbaWordDiffGenerator.java b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/util/VbaWordDiffGenerator.java
index 521433d792..8f9c613cae 100644
--- a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/util/VbaWordDiffGenerator.java
+++ b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/util/VbaWordDiffGenerator.java
@@ -10,13 +10,19 @@
*******************************************************************************/
package org.eclipse.osee.framework.ui.skynet.util;
+import java.io.BufferedReader;
import java.io.File;
import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.util.logging.Level;
import org.eclipse.core.resources.IFile;
import org.eclipse.osee.framework.core.exception.OseeCoreException;
import org.eclipse.osee.framework.core.exception.OseeExceptions;
import org.eclipse.osee.framework.jdk.core.util.Lib;
-import org.eclipse.osee.framework.jdk.core.util.io.streams.StreamCatcher;
+import org.eclipse.osee.framework.logging.OseeLevel;
+import org.eclipse.osee.framework.logging.OseeLog;
+import org.eclipse.osee.framework.ui.skynet.SkynetGuiPlugin;
/**
* @author Theron Virgin
@@ -143,12 +149,31 @@ public class VbaWordDiffGenerator implements IVbaDiffGenerator {
private void executeScript(File vbDiffScript) throws OseeCoreException {
Process process = null;
try {
- String cmd[] = {"cmd", "/s", "/c", "\"" + vbDiffScript.getPath() + "\""};
+ String target = vbDiffScript.getName();
+ String cmd[] = {"cmd", "/s", "/c", "\"" + target + "\""};
ProcessBuilder builder = new ProcessBuilder(cmd);
+
+ File parentDir = vbDiffScript.getParentFile();
+ if (parentDir != null) {
+ builder.directory(parentDir);
+ }
process = builder.start();
- StreamCatcher errorCatcher = new StreamCatcher(process.getErrorStream(), "ERROR");
- StreamCatcher outputCatcher = new StreamCatcher(process.getInputStream(), "OUTPUT");
+ Thread errorCatcher = new StreamLogger(process.getErrorStream()) {
+
+ @Override
+ protected void log(String message) {
+ OseeLog.log(SkynetGuiPlugin.class, OseeLevel.SEVERE_POPUP, message);
+ }
+
+ };
+ Thread outputCatcher = new StreamLogger(process.getInputStream()) {
+
+ @Override
+ protected void log(String message) {
+ OseeLog.log(SkynetGuiPlugin.class, Level.INFO, message);
+ }
+ };
errorCatcher.start();
outputCatcher.start();
@@ -161,4 +186,36 @@ public class VbaWordDiffGenerator implements IVbaDiffGenerator {
}
}
}
+
+ private static abstract class StreamLogger extends Thread {
+
+ private final InputStream inputStream;
+
+ protected StreamLogger(InputStream inputStream) {
+ this.inputStream = inputStream;
+ }
+
+ @Override
+ public void run() {
+ InputStreamReader isr = new InputStreamReader(inputStream);
+ BufferedReader br = new BufferedReader(isr);
+ try {
+ StringBuilder message = new StringBuilder();
+
+ String line = null;
+ while ((line = br.readLine()) != null) {
+ message.append(line);
+ message.append("\n");
+ }
+ if (message.length() > 0) {
+ log(message.toString());
+ }
+ } catch (IOException ioe) {
+ ioe.printStackTrace();
+ }
+ }
+
+ protected abstract void log(String message);
+ }
+
}

Back to the top