From 4dc4aa0c15b318b761b92e2394d0fde58a3e8232 Mon Sep 17 00:00:00 2001
From: jvergara <jvergara@localhost>
Date: Tue, 18 Dec 2007 11:24:28 +0000
Subject: [PATCH] Fix for issue 1862 (verbosity options for quicksetup tools)
---
opends/src/quicksetup/org/opends/quicksetup/Application.java | 126 +++++++++++++++++++++++++----------------
1 files changed, 76 insertions(+), 50 deletions(-)
diff --git a/opends/src/quicksetup/org/opends/quicksetup/Application.java b/opends/src/quicksetup/org/opends/quicksetup/Application.java
index 7498b28..522651e 100644
--- a/opends/src/quicksetup/org/opends/quicksetup/Application.java
+++ b/opends/src/quicksetup/org/opends/quicksetup/Application.java
@@ -78,6 +78,8 @@
private ApplicationTrustManager trustManager;
+ private boolean notifyListeners = true;
+
/** Formats progress messages. */
protected ProgressMessageFormatter formatter;
@@ -219,11 +221,11 @@
/**
* This method notifies the ProgressUpdateListeners that there was an
* update in the installation progress.
- * @param ratioWhenCompleted the integer that specifies which percentage of
- * the whole installation has been completed.
+ * @param ratio the integer that specifies which percentage of the whole
+ * installation has been completed.
*/
- public void notifyListenersDone(Integer ratioWhenCompleted) {
- notifyListeners(ratioWhenCompleted,
+ public void notifyListenersDone(Integer ratio) {
+ notifyListeners(ratio,
getSummary(getCurrentProgressStep()),
getFormattedDoneWithLineBreak());
}
@@ -231,6 +233,18 @@
/**
* This method notifies the ProgressUpdateListeners that there was an
* update in the installation progress.
+ * @param ratio the integer that specifies which percentage of the whole
+ * installation has been completed.
+ */
+ public void notifyListenersRatioChange(Integer ratio) {
+ notifyListeners(ratio,
+ getSummary(getCurrentProgressStep()),
+ null);
+ }
+
+ /**
+ * This method notifies the ProgressUpdateListeners that there was an
+ * update in the installation progress.
* @param ratio the integer that specifies which percentage of
* the whole installation has been completed.
* @param currentPhaseSummary the localized summary message for the
@@ -241,8 +255,11 @@
public void notifyListeners(Integer ratio, Message currentPhaseSummary,
Message newLogDetail)
{
- listenerDelegate.notifyListeners(getCurrentProgressStep(),
+ if (notifyListeners)
+ {
+ listenerDelegate.notifyListeners(getCurrentProgressStep(),
ratio, currentPhaseSummary, newLogDetail);
+ }
}
/**
@@ -250,12 +267,12 @@
* update in the installation progress.
* @param ratio the integer that specifies which percentage of
* the whole installation has been completed.
- * @param currentPhaseSummary the localized summary message for the
- * current installation progress in formatted form.
+ * @param newLogDetail the localized additional log message.
*/
- public void notifyListeners(Integer ratio, Message currentPhaseSummary) {
+ public void notifyListenersWithPoints(Integer ratio,
+ Message newLogDetail) {
notifyListeners(ratio, getSummary(getCurrentProgressStep()),
- formatter.getFormattedWithPoints(currentPhaseSummary));
+ formatter.getFormattedWithPoints(newLogDetail));
}
/**
@@ -764,12 +781,23 @@
}
/**
+ * Returns <CODE>true</CODE> if the application is running in verbose mode and
+ * <CODE>false</CODE> otherwise.
+ * @return <CODE>true</CODE> if the application is running in verbose mode and
+ * <CODE>false</CODE> otherwise.
+ */
+ public boolean isVerbose()
+ {
+ return getUserData().isVerbose();
+ }
+
+ /**
* Returns the error stream to be used by the application when launching
* command lines.
* @return the error stream to be used by the application when launching
* command lines.
*/
- protected ErrorPrintStream getApplicationErrorStream()
+ public ErrorPrintStream getApplicationErrorStream()
{
return err;
}
@@ -780,10 +808,35 @@
* @return the output stream to be used by the application when launching
* command lines.
*/
- protected OutputPrintStream getApplicationOutputStream()
+ public OutputPrintStream getApplicationOutputStream()
{
return out;
}
+
+
+
+ /**
+ * Notifies the progress update listeners of the application of the message
+ * we received.
+ * @return <CODE>true</CODE> if we must notify the application listeners
+ * of the message and <CODE>false</CODE> otherwise.
+ */
+ public boolean isNotifyListeners()
+ {
+ return notifyListeners;
+ }
+
+ /**
+ * Tells whether we must notify the listeners or not of the message
+ * received.
+ * @param notifyListeners the boolean that informs of whether we have
+ * to notify the listeners or not.
+ */
+ public void setNotifyListeners(boolean notifyListeners)
+ {
+ this.notifyListeners = notifyListeners;
+ }
+
/**
* This class is used to notify the ProgressUpdateListeners of events
* that are written to the standard error. It is used in WebStartInstaller
@@ -795,7 +848,7 @@
* ProgressUpdateListeners with the formatted messages.
*
*/
- protected class ErrorPrintStream extends ApplicationPrintStream {
+ public class ErrorPrintStream extends ApplicationPrintStream {
/**
* Default constructor.
@@ -825,7 +878,7 @@
* ProgressUpdateListeners with the formatted messages.
*
*/
- protected class OutputPrintStream extends ApplicationPrintStream
+ public class OutputPrintStream extends ApplicationPrintStream
{
/**
@@ -853,8 +906,6 @@
private boolean isFirstLine;
- private boolean notifyListeners = true;
-
/**
* Format a string before sending a listener notification.
* @param string to format
@@ -878,23 +929,20 @@
@Override
public void println(String msg)
{
- if (notifyListeners)
+ MessageBuilder mb = new MessageBuilder();
+ if (isFirstLine)
{
- MessageBuilder mb = new MessageBuilder();
- if (isFirstLine)
+ mb.append(formatString(msg));
+ } else
+ {
+ if (!Utils.isCli())
{
- mb.append(formatString(msg));
- } else
- {
- if (!Utils.isCli())
- {
- mb.append(getLineBreak());
- }
- mb.append(formatString(msg));
+ mb.append(getLineBreak());
}
-
- notifyListeners(mb.toMessage());
+ mb.append(formatString(msg));
}
+
+ notifyListeners(mb.toMessage());
LOG.log(Level.INFO, "server: " + msg);
isFirstLine = false;
}
@@ -917,27 +965,5 @@
}
println(new String(b, off, len));
}
-
- /**
- * Notifies the progress update listeners of the application of the message
- * we received.
- * @return <CODE>true</CODE> if we must notify the application listeners
- * of the message and <CODE>false</CODE> otherwise.
- */
- public boolean isNotifyListeners()
- {
- return notifyListeners;
- }
-
- /**
- * Tells whether we must notify the listeners or not of the message
- * received.
- * @param notifyListeners the boolean that informs of whether we have
- * to notify the listeners or not.
- */
- public void setNotifyListeners(boolean notifyListeners)
- {
- this.notifyListeners = notifyListeners;
- }
}
}
--
Gitblit v1.10.0