Commit a20bbd77 authored by Kristof Szabados's avatar Kristof Szabados
Browse files

hopefully the code became somewhat more readable.


Signed-off-by: Kristof Szabados's avatarKristof Szabados <Kristof.Szabados@ericsson.com>
parent c71c9b26
...@@ -84,8 +84,10 @@ public final class HostJob extends Job { ...@@ -84,8 +84,10 @@ public final class HostJob extends Job {
final int exitVal = proc.waitFor(); final int exitVal = proc.waitFor();
if (0 == exitVal) { if (0 == exitVal) {
executor.addNotification(new Notification((new Formatter()).format(BaseExecutor.PADDEDDATETIMEFORMAT, new Date()).toString(), EMPTY, final Formatter formatter = new Formatter();
EMPTY, "Host Controller executed successfully")); final String timestamp = formatter.format(BaseExecutor.PADDEDDATETIMEFORMAT, new Date()).toString();
formatter.close();
executor.addNotification(new Notification(timestamp, EMPTY, EMPTY, "Host Controller executed successfully"));
} else { } else {
if (stderr.ready()) { if (stderr.ready()) {
final Formatter formatter = new Formatter(); final Formatter formatter = new Formatter();
...@@ -148,7 +150,10 @@ public final class HostJob extends Job { ...@@ -148,7 +150,10 @@ public final class HostJob extends Job {
fastOffset = 0; fastOffset = 0;
readFullLineOnly(stdout); readFullLineOnly(stdout);
while (null != fastLine) { while (null != fastLine) {
executor.addNotification(new Notification((new Formatter()).format(BaseExecutor.PADDEDDATETIMEFORMAT, new Date()).toString(), "", "", fastLine)); final Formatter formatter = new Formatter();
final String timestamp = formatter.format(BaseExecutor.PADDEDDATETIMEFORMAT, new Date()).toString();
formatter.close();
executor.addNotification(new Notification(timestamp, "", "", fastLine));
builder.delete(0, fastOffset); builder.delete(0, fastOffset);
if (!firstOutput && null != Activator.getMainView()) { if (!firstOutput && null != Activator.getMainView()) {
Activator.getMainView().refreshIfSelected(executor.mainControllerRoot); Activator.getMainView().refreshIfSelected(executor.mainControllerRoot);
......
...@@ -317,11 +317,13 @@ public class NativeJavaExecutor extends BaseExecutor { ...@@ -317,11 +317,13 @@ public class NativeJavaExecutor extends BaseExecutor {
public void insertError(final int severity, final String msg) { public void insertError(final int severity, final String msg) {
TITANConsole.println("Error: " + msg); TITANConsole.println("Error: " + msg);
final Formatter formatter = new Formatter();
final String timestamp = formatter.format(PADDEDDATETIMEFORMAT, new Date()).toString();
formatter.close();
if (severityLevelExtraction) { if (severityLevelExtraction) {
addNotification(new Notification((new Formatter()).format(PADDEDDATETIMEFORMAT, new Date()).toString(), addNotification(new Notification(timestamp, SeverityResolver.getSeverityString(severity), EMPTY_STRING, msg));
SeverityResolver.getSeverityString(severity), EMPTY_STRING, msg));
} else { } else {
addNotification(new Notification((new Formatter()).format(PADDEDDATETIMEFORMAT, new Date()).toString(), EMPTY_STRING, EMPTY_STRING, msg)); addNotification(new Notification(timestamp, EMPTY_STRING, EMPTY_STRING, msg));
} }
if (simpleExecutionRunning) { if (simpleExecutionRunning) {
shutdownRequested = true; shutdownRequested = true;
......
...@@ -297,11 +297,13 @@ public final class JniExecutor extends BaseExecutor implements IJNICallback { ...@@ -297,11 +297,13 @@ public final class JniExecutor extends BaseExecutor implements IJNICallback {
public void insertError(final int severity, final String msg) { public void insertError(final int severity, final String msg) {
TITANConsole.println("Error: " + msg); TITANConsole.println("Error: " + msg);
final Formatter formatter = new Formatter();
final String timestamp = formatter.format(PADDEDDATETIMEFORMAT, new Date()).toString();
formatter.close();
if (severityLevelExtraction) { if (severityLevelExtraction) {
addNotification(new Notification((new Formatter()).format(PADDEDDATETIMEFORMAT, new Date()).toString(), SeverityResolver addNotification(new Notification(timestamp, SeverityResolver.getSeverityString(severity), EMPTY_STRING, msg));
.getSeverityString(severity), EMPTY_STRING, msg));
} else { } else {
addNotification(new Notification((new Formatter()).format(PADDEDDATETIMEFORMAT, new Date()).toString(), EMPTY_STRING, EMPTY_STRING, msg)); addNotification(new Notification(timestamp, EMPTY_STRING, EMPTY_STRING, msg));
} }
if (simpleExecutionRunning) { if (simpleExecutionRunning) {
shutdownRequested = true; shutdownRequested = true;
......
...@@ -960,7 +960,10 @@ public final class CliExecutor extends BaseExecutor { ...@@ -960,7 +960,10 @@ public final class CliExecutor extends BaseExecutor {
} else if ( consoleTimeStampLength < fastLine.length() && } else if ( consoleTimeStampLength < fastLine.length() &&
fastLine.substring(consoleTimeStampLength).startsWith("MTC@")) { fastLine.substring(consoleTimeStampLength).startsWith("MTC@")) {
fastLine = fastLine.substring(consoleTimeStampLength); fastLine = fastLine.substring(consoleTimeStampLength);
addNotification(new Notification((new Formatter()).format(PADDEDDATETIMEFORMAT, new Date()).toString(), "", "", fastLine)); final Formatter formatter = new Formatter();
final String timestamp = formatter.format(PADDEDDATETIMEFORMAT, new Date()).toString();
formatter.close();
addNotification(new Notification(timestamp, "", "", fastLine));
testExecution(); testExecution();
} else if ( consoleTimeStampLength < fastLine.length() && } else if ( consoleTimeStampLength < fastLine.length() &&
fastLine.substring(consoleTimeStampLength).startsWith("MC@")) { fastLine.substring(consoleTimeStampLength).startsWith("MC@")) {
...@@ -1012,7 +1015,10 @@ public final class CliExecutor extends BaseExecutor { ...@@ -1012,7 +1015,10 @@ public final class CliExecutor extends BaseExecutor {
} }
} else if ( consoleTimeStampLength < fastLine.length() && fastLine.substring(consoleTimeStampLength).startsWith("HC@")) { } else if ( consoleTimeStampLength < fastLine.length() && fastLine.substring(consoleTimeStampLength).startsWith("HC@")) {
fastLine = fastLine.substring(consoleTimeStampLength); fastLine = fastLine.substring(consoleTimeStampLength);
addNotification(new Notification((new Formatter()).format(PADDEDDATETIMEFORMAT, new Date()).toString(), "", "", fastLine)); final Formatter formatter = new Formatter();
final String timestamp = formatter.format(PADDEDDATETIMEFORMAT, new Date()).toString();
formatter.close();
addNotification(new Notification(timestamp, "", "", fastLine));
} else { } else {
//to avoid expensive steps and using cheap comparisons instead, if possible: //to avoid expensive steps and using cheap comparisons instead, if possible:
if ( consoleTimeStampLength > 0 && consoleTimeStampLength < fastLine.length() ) { if ( consoleTimeStampLength > 0 && consoleTimeStampLength < fastLine.length() ) {
...@@ -1021,7 +1027,10 @@ public final class CliExecutor extends BaseExecutor { ...@@ -1021,7 +1027,10 @@ public final class CliExecutor extends BaseExecutor {
fastLine = fastLine.substring(consoleTimeStampLength); fastLine = fastLine.substring(consoleTimeStampLength);
} }
} }
addNotification(new Notification((new Formatter()).format(PADDEDDATETIMEFORMAT, new Date()).toString(), "", "", fastLine)); final Formatter formatter = new Formatter();
final String timestamp = formatter.format(PADDEDDATETIMEFORMAT, new Date()).toString();
formatter.close();
addNotification(new Notification(timestamp, "", "", fastLine));
} }
builder.delete(0, fastOffset); builder.delete(0, fastOffset);
if (Activator.getMainView() != null) { if (Activator.getMainView() != null) {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment