diff --git a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/dialogs/SystemPromptDialog.java b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/dialogs/SystemPromptDialog.java index 9e09d553d5e..1366df6cd29 100644 --- a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/dialogs/SystemPromptDialog.java +++ b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/dialogs/SystemPromptDialog.java @@ -781,7 +781,6 @@ public abstract class SystemPromptDialog { //System.out.println("INSIDE CREATEMESSAGELINE"); fMessageLine= new SystemMessageLine(c); - fMessageLine.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, true)); Display.getCurrent().asyncExec(this); return fMessageLine; } diff --git a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/messages/ISystemMessageLine.java b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/messages/ISystemMessageLine.java index 42d84997616..67906a929cb 100644 --- a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/messages/ISystemMessageLine.java +++ b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/messages/ISystemMessageLine.java @@ -20,28 +20,29 @@ import org.eclipse.rse.services.clientserver.messages.SystemMessage; /** * A message line interface. It distinguishs between "normal" messages and errors, as does the - * DialogPage classes in eclipse. + * DialogPage classes in eclipse. *
* For each of those, however, we also support both simple string msgs and more robust SystemMessage - * messages. A dialog, wizard page or property page class that implements this interface will support - * these by using getLevelOneText() to get the string for the first level text, and support mouse - * clicking on the message to display the SystemMessageDialog class to show the 2nd level text. + * messages. A dialog, wizard page or property page class that implements this interface will support + * these by using getLevelOneText() to get the string for the first level text, and support mouse + * clicking on the message to display the SystemMessageDialog class to show the 2nd level text. *
* Setting an error message hides a currently displayed message until
* clearErrorMessage
is called.
- */
-public interface ISystemMessageLine
-{
+ */
+public interface ISystemMessageLine {
/**
* Clears the currently displayed error message and redisplayes
- * the message which was active before the error message was set.
+ * the non-error message which was active before the error message was set (if any).
*/
public void clearErrorMessage();
+
/**
* Clears the currently displayed message.
*/
public void clearMessage();
+
/**
* Get the currently displayed error text.
* @return The error message. If no error message is displayed null
is returned.
@@ -53,6 +54,7 @@ public interface ISystemMessageLine
* @return The error message. If no error message is displayed null
is returned.
*/
public SystemMessage getSystemErrorMessage();
+
/**
* Get the currently displayed message.
* @return The message. If no message is displayed null
is returned.
@@ -60,31 +62,33 @@ public interface ISystemMessageLine
public String getMessage();
/**
- * Display the given error message. A currently displayed message
+ * Display the given error message. A currently displayed (non-error) message
* is saved and will be redisplayed when the error message is cleared.
*/
public void setErrorMessage(String message);
/**
- * Display the given error message. A currently displayed message
+ * Display the given error message. A currently displayed (non-error) message
* is saved and will be redisplayed when the error message is cleared.
*/
public void setErrorMessage(SystemMessage message);
+
/**
* Display the given exception as an error message. This is a convenience
* method... a generic SystemMessage is used for exceptions.
*/
public void setErrorMessage(Throwable exc);
+
/**
* Set the message text. If the message line currently displays an error,
- * the message is stored and will be shown after a call to clearErrorMessage
+ * the message is stored and will be shown after a call to clearErrorMessage.
*/
public void setMessage(String message);
/**
- *If the message line currently displays an error,
+ * If the message line currently displays an error,
* the message is stored and will be shown after a call to clearErrorMessage
*/
public void setMessage(SystemMessage message);
-
+
}
\ No newline at end of file
diff --git a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/messages/SystemMessageLine.java b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/messages/SystemMessageLine.java
index c57a93211b5..20bdf6e5412 100644
--- a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/messages/SystemMessageLine.java
+++ b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/messages/SystemMessageLine.java
@@ -187,7 +187,7 @@ public class SystemMessageLine extends Composite implements ISystemMessageLine {
* @see org.eclipse.rse.ui.messages.SystemMessageLine.MyMessage#getTooltip()
*/
String getTooltip() {
- return message.getFullMessageID() + ": " + getText();
+ return message.getFullMessageID() + ": " + getText(); //$NON-NLS-1$
}
/* (non-Javadoc)
@@ -244,7 +244,7 @@ public class SystemMessageLine extends Composite implements ISystemMessageLine {
private class MyImpromptuMessage extends MyMessage {
private int type = NONE;
- private String text1 = "";
+ private String text1 = ""; //$NON-NLS-1$
private String text2 = null;
/**
@@ -335,10 +335,15 @@ public class SystemMessageLine extends Composite implements ISystemMessageLine {
}
/**
- * Creates a new message line as a child of the given parent.
+ * Creates a new message line as a child of the given parent. If the parent
+ * uses a grid layout then the layout data is set. If not then the layout data
+ * must be set by the creator to match the layout of the parent composite.
*/
public SystemMessageLine(Composite parent) {
super(parent, SWT.NONE);
+ if (parent.getLayout() instanceof GridLayout) {
+ setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
+ }
GridLayout layout = new GridLayout();
layout.numColumns = 3;
layout.verticalSpacing = 0;
@@ -431,27 +436,36 @@ public class SystemMessageLine extends Composite implements ISystemMessageLine {
* @see org.eclipse.rse.ui.messages.ISystemMessageLine#getErrorMessage()
*/
public String getErrorMessage() {
+ String result = null;
MyMessage message = getTopMessage();
- if (message != null && message.isError()) return message.getText();
- return null;
+ if (message != null && message.isError()) {
+ result = message.getText();
+ }
+ return result;
}
/* (non-Javadoc)
* @see org.eclipse.rse.ui.messages.ISystemMessageLine#getMessage()
*/
public String getMessage() {
+ String result = null;
MyMessage message = getTopMessage();
- if (message != null && !message.isError()) return message.getText();
- return null;
+ if (message != null && !message.isError()) {
+ result = message.getText();
+ }
+ return result;
}
/* (non-Javadoc)
* @see org.eclipse.rse.ui.messages.ISystemMessageLine#getSystemErrorMessage()
*/
public SystemMessage getSystemErrorMessage() {
+ SystemMessage result = null;
MyMessage message = getTopMessage();
- if (message != null && message.isError()) return message.toSystemMessage();
- return null;
+ if (message != null && message.isError()) {
+ result = message.toSystemMessage();
+ }
+ return result;
}
/* (non-Javadoc)
@@ -459,7 +473,7 @@ public class SystemMessageLine extends Composite implements ISystemMessageLine {
*/
public void setErrorMessage(String message) {
MyMessage temp = new MyImpromptuMessage(ERROR, message);
- pushMessage(temp);
+ setErrorMessage(temp);
}
/* (non-Javadoc)
@@ -467,9 +481,22 @@ public class SystemMessageLine extends Composite implements ISystemMessageLine {
*/
public void setErrorMessage(SystemMessage message) {
MyMessage temp = new MySystemMessage(message);
- pushMessage(temp);
+ setErrorMessage(temp);
logMessage(message);
}
+
+ /**
+ * Place an error message on the stack. Removes the previous error message if one
+ * is on the top of the stack. Leaves any other messages on the stack.
+ * @param message
+ */
+ private void setErrorMessage(MyMessage message) {
+ MyMessage top = getTopMessage();
+ if (top != null && top.getType() == ERROR) {
+ popMessage();
+ }
+ pushMessage(message);
+ }
/* (non-Javadoc)
* @see org.eclipse.rse.ui.messages.ISystemMessageLine#setErrorMessage(java.lang.Throwable)
@@ -480,27 +507,39 @@ public class SystemMessageLine extends Composite implements ISystemMessageLine {
setErrorMessage(message);
}
- /**
- * Set the message text. If the message line currently displays an error,
- * the message is stored and will be shown after a call to clearErrorMessage.
+ /* (non-Javadoc)
+ * @see org.eclipse.rse.ui.messages.ISystemMessageLine#setMessage(java.lang.String)
*/
public void setMessage(String message) {
MyMessage temp = new MyImpromptuMessage(INFO, message);
- pushMessage(temp);
+ setMessage(temp);
}
- /**
- * Set the non-error message text, using a SystemMessage object.
- * If the message line currently displays an error,
- * the message is stored and will be shown after a call to clearMessage.
- * The SystemMessage text is always shown as a "non-error".
+ /* (non-Javadoc)
+ * @see org.eclipse.rse.ui.messages.ISystemMessageLine#setMessage(org.eclipse.rse.services.clientserver.messages.SystemMessage)
*/
public void setMessage(SystemMessage message) {
MyMessage temp = new MySystemMessage(message);
if (temp.isError()) {
temp = new MyImpromptuMessage(NONE, message.getLevelOneText(), message.getLevelTwoText());
}
- pushMessage(temp);
+ setMessage(temp);
+ }
+
+ /**
+ * Sets the non-error message for the message line. If there is an error message on the top of the stack
+ * then this is placed "underneath" that message. If there is a non-error message on the top then
+ * it replaces that message.
+ * @param message
+ */
+ private void setMessage(MyMessage message) {
+ MyMessage top = getTopMessage();
+ messageStack.clear();
+ if (top.getType() == ERROR) {
+ messageStack.push(message);
+ message = top;
+ }
+ pushMessage(message);
}
/**
@@ -516,7 +555,9 @@ public class SystemMessageLine extends Composite implements ISystemMessageLine {
* Pops a message off the message stack and shows the new top message.
*/
private void popMessage() {
- if (!messageStack.isEmpty()) messageStack.pop();
+ if (!messageStack.isEmpty()) {
+ messageStack.pop();
+ }
showTopMessage();
}
@@ -525,8 +566,11 @@ public class SystemMessageLine extends Composite implements ISystemMessageLine {
* @return A MyMessage or null if the stack is empty.
*/
private MyMessage getTopMessage() {
- if (messageStack.isEmpty()) return null;
- return (MyMessage) messageStack.peek();
+ MyMessage result = null;
+ if (!messageStack.isEmpty()) {
+ result = (MyMessage) messageStack.peek();
+ }
+ return result;
}
/**
@@ -555,7 +599,7 @@ public class SystemMessageLine extends Composite implements ISystemMessageLine {
* @param message the message from which to get the text.
*/
private void setText(MyMessage message) {
- String text = "";
+ String text = ""; //$NON-NLS-1$
String toolTip = null;
Color color = null;
if (message != null) {
@@ -597,13 +641,13 @@ public class SystemMessageLine extends Composite implements ISystemMessageLine {
if (gc.stringExtent(text).x > maxWidth) {
StringBuffer head = new StringBuffer(text);
int n = head.length();
- head.append("...");
+ head.append("..."); //$NON-NLS-1$
while (n > 0) {
text = head.toString();
if (gc.stringExtent(text).x <= maxWidth) break;
head.deleteCharAt(--n);
}
- if (n == 0) text = "";
+ if (n == 0) text = ""; //$NON-NLS-1$
}
widget.setText(text);
}
@@ -621,9 +665,9 @@ public class SystemMessageLine extends Composite implements ISystemMessageLine {
Object object = data[i];
StringBuffer buffer = new StringBuffer(200);
buffer.append(m.getID());
- buffer.append(": SUB#");
+ buffer.append(": SUB#"); //$NON-NLS-1$
buffer.append(Integer.toString(i));
- buffer.append(":");
+ buffer.append(":"); //$NON-NLS-1$
buffer.append(object.toString());
logMessage(m.getType(), buffer.toString(), false);
}
@@ -640,7 +684,7 @@ public class SystemMessageLine extends Composite implements ISystemMessageLine {
private void logMessage(int type, String text, boolean stackTrace) {
switch (type) {
case ERROR:
- Exception e = stackTrace ? new Exception("Stack Trace") : null;
+ Exception e = stackTrace ? new Exception("Stack Trace") : null; //$NON-NLS-1$
SystemBasePlugin.logError(text, e);
break;
case WARNING:
diff --git a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/wizards/AbstractSystemWizardPage.java b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/wizards/AbstractSystemWizardPage.java
index 532f0475870..45f421037a4 100644
--- a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/wizards/AbstractSystemWizardPage.java
+++ b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/wizards/AbstractSystemWizardPage.java
@@ -259,7 +259,7 @@ public abstract class AbstractSystemWizardPage
// dwd parentComposite = parent;
Composite myComposite = new Composite(parent, SWT.NONE);
myComposite.setLayout(new GridLayout(1, false));
- GridData gd = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING, GridData.VERTICAL_ALIGN_BEGINNING, true, false);
+ GridData gd = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING, GridData.VERTICAL_ALIGN_BEGINNING, true, true);
myComposite.setLayoutData(gd);
parentComposite = myComposite;
Control c = createContents(myComposite);
@@ -278,7 +278,6 @@ public abstract class AbstractSystemWizardPage
}
// dwd configureMessageLine();
msgLine = new SystemMessageLine(myComposite);
- msgLine.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, true));
if (pendingMessage!=null)
setMessage(pendingMessage);
if (pendingErrorMessage!=null)