mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-08-15 12:15:47 +02:00
Bugs 158305 and 158333 - Removed unrestricted stacking behavior for message lines and fixed vertical space on resize.
The message line now behaves according to specification. Messages are of two types: error and non-error. Both may be set. Error messages have precedence in the display.
This commit is contained in:
parent
6ae8d859b8
commit
22e7a51e6b
4 changed files with 92 additions and 46 deletions
|
@ -781,7 +781,6 @@ public abstract class SystemPromptDialog
|
||||||
{
|
{
|
||||||
//System.out.println("INSIDE CREATEMESSAGELINE");
|
//System.out.println("INSIDE CREATEMESSAGELINE");
|
||||||
fMessageLine= new SystemMessageLine(c);
|
fMessageLine= new SystemMessageLine(c);
|
||||||
fMessageLine.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, true));
|
|
||||||
Display.getCurrent().asyncExec(this);
|
Display.getCurrent().asyncExec(this);
|
||||||
return fMessageLine;
|
return fMessageLine;
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,18 +30,19 @@ import org.eclipse.rse.services.clientserver.messages.SystemMessage;
|
||||||
* Setting an error message hides a currently displayed message until
|
* Setting an error message hides a currently displayed message until
|
||||||
* <code>clearErrorMessage</code> is called.
|
* <code>clearErrorMessage</code> is called.
|
||||||
*/
|
*/
|
||||||
public interface ISystemMessageLine
|
public interface ISystemMessageLine {
|
||||||
{
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Clears the currently displayed error message and redisplayes
|
* 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();
|
public void clearErrorMessage();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Clears the currently displayed message.
|
* Clears the currently displayed message.
|
||||||
*/
|
*/
|
||||||
public void clearMessage();
|
public void clearMessage();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the currently displayed error text.
|
* Get the currently displayed error text.
|
||||||
* @return The error message. If no error message is displayed <code>null</code> is returned.
|
* @return The error message. If no error message is displayed <code>null</code> is returned.
|
||||||
|
@ -53,6 +54,7 @@ public interface ISystemMessageLine
|
||||||
* @return The error message. If no error message is displayed <code>null</code> is returned.
|
* @return The error message. If no error message is displayed <code>null</code> is returned.
|
||||||
*/
|
*/
|
||||||
public SystemMessage getSystemErrorMessage();
|
public SystemMessage getSystemErrorMessage();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the currently displayed message.
|
* Get the currently displayed message.
|
||||||
* @return The message. If no message is displayed <code>null<code> is returned.
|
* @return The message. If no message is displayed <code>null<code> is returned.
|
||||||
|
@ -60,24 +62,26 @@ public interface ISystemMessageLine
|
||||||
public String getMessage();
|
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.
|
* is saved and will be redisplayed when the error message is cleared.
|
||||||
*/
|
*/
|
||||||
public void setErrorMessage(String message);
|
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.
|
* is saved and will be redisplayed when the error message is cleared.
|
||||||
*/
|
*/
|
||||||
public void setErrorMessage(SystemMessage message);
|
public void setErrorMessage(SystemMessage message);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Display the given exception as an error message. This is a convenience
|
* Display the given exception as an error message. This is a convenience
|
||||||
* method... a generic SystemMessage is used for exceptions.
|
* method... a generic SystemMessage is used for exceptions.
|
||||||
*/
|
*/
|
||||||
public void setErrorMessage(Throwable exc);
|
public void setErrorMessage(Throwable exc);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the message text. If the message line currently displays an error,
|
* 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);
|
public void setMessage(String message);
|
||||||
|
|
||||||
|
|
|
@ -187,7 +187,7 @@ public class SystemMessageLine extends Composite implements ISystemMessageLine {
|
||||||
* @see org.eclipse.rse.ui.messages.SystemMessageLine.MyMessage#getTooltip()
|
* @see org.eclipse.rse.ui.messages.SystemMessageLine.MyMessage#getTooltip()
|
||||||
*/
|
*/
|
||||||
String getTooltip() {
|
String getTooltip() {
|
||||||
return message.getFullMessageID() + ": " + getText();
|
return message.getFullMessageID() + ": " + getText(); //$NON-NLS-1$
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
|
@ -244,7 +244,7 @@ public class SystemMessageLine extends Composite implements ISystemMessageLine {
|
||||||
private class MyImpromptuMessage extends MyMessage {
|
private class MyImpromptuMessage extends MyMessage {
|
||||||
|
|
||||||
private int type = NONE;
|
private int type = NONE;
|
||||||
private String text1 = "";
|
private String text1 = ""; //$NON-NLS-1$
|
||||||
private String text2 = null;
|
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) {
|
public SystemMessageLine(Composite parent) {
|
||||||
super(parent, SWT.NONE);
|
super(parent, SWT.NONE);
|
||||||
|
if (parent.getLayout() instanceof GridLayout) {
|
||||||
|
setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
|
||||||
|
}
|
||||||
GridLayout layout = new GridLayout();
|
GridLayout layout = new GridLayout();
|
||||||
layout.numColumns = 3;
|
layout.numColumns = 3;
|
||||||
layout.verticalSpacing = 0;
|
layout.verticalSpacing = 0;
|
||||||
|
@ -431,27 +436,36 @@ public class SystemMessageLine extends Composite implements ISystemMessageLine {
|
||||||
* @see org.eclipse.rse.ui.messages.ISystemMessageLine#getErrorMessage()
|
* @see org.eclipse.rse.ui.messages.ISystemMessageLine#getErrorMessage()
|
||||||
*/
|
*/
|
||||||
public String getErrorMessage() {
|
public String getErrorMessage() {
|
||||||
|
String result = null;
|
||||||
MyMessage message = getTopMessage();
|
MyMessage message = getTopMessage();
|
||||||
if (message != null && message.isError()) return message.getText();
|
if (message != null && message.isError()) {
|
||||||
return null;
|
result = message.getText();
|
||||||
|
}
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.rse.ui.messages.ISystemMessageLine#getMessage()
|
* @see org.eclipse.rse.ui.messages.ISystemMessageLine#getMessage()
|
||||||
*/
|
*/
|
||||||
public String getMessage() {
|
public String getMessage() {
|
||||||
|
String result = null;
|
||||||
MyMessage message = getTopMessage();
|
MyMessage message = getTopMessage();
|
||||||
if (message != null && !message.isError()) return message.getText();
|
if (message != null && !message.isError()) {
|
||||||
return null;
|
result = message.getText();
|
||||||
|
}
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.rse.ui.messages.ISystemMessageLine#getSystemErrorMessage()
|
* @see org.eclipse.rse.ui.messages.ISystemMessageLine#getSystemErrorMessage()
|
||||||
*/
|
*/
|
||||||
public SystemMessage getSystemErrorMessage() {
|
public SystemMessage getSystemErrorMessage() {
|
||||||
|
SystemMessage result = null;
|
||||||
MyMessage message = getTopMessage();
|
MyMessage message = getTopMessage();
|
||||||
if (message != null && message.isError()) return message.toSystemMessage();
|
if (message != null && message.isError()) {
|
||||||
return null;
|
result = message.toSystemMessage();
|
||||||
|
}
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
|
@ -459,7 +473,7 @@ public class SystemMessageLine extends Composite implements ISystemMessageLine {
|
||||||
*/
|
*/
|
||||||
public void setErrorMessage(String message) {
|
public void setErrorMessage(String message) {
|
||||||
MyMessage temp = new MyImpromptuMessage(ERROR, message);
|
MyMessage temp = new MyImpromptuMessage(ERROR, message);
|
||||||
pushMessage(temp);
|
setErrorMessage(temp);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
|
@ -467,10 +481,23 @@ public class SystemMessageLine extends Composite implements ISystemMessageLine {
|
||||||
*/
|
*/
|
||||||
public void setErrorMessage(SystemMessage message) {
|
public void setErrorMessage(SystemMessage message) {
|
||||||
MyMessage temp = new MySystemMessage(message);
|
MyMessage temp = new MySystemMessage(message);
|
||||||
pushMessage(temp);
|
setErrorMessage(temp);
|
||||||
logMessage(message);
|
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)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.rse.ui.messages.ISystemMessageLine#setErrorMessage(java.lang.Throwable)
|
* @see org.eclipse.rse.ui.messages.ISystemMessageLine#setErrorMessage(java.lang.Throwable)
|
||||||
*/
|
*/
|
||||||
|
@ -480,27 +507,39 @@ public class SystemMessageLine extends Composite implements ISystemMessageLine {
|
||||||
setErrorMessage(message);
|
setErrorMessage(message);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/* (non-Javadoc)
|
||||||
* Set the message text. If the message line currently displays an error,
|
* @see org.eclipse.rse.ui.messages.ISystemMessageLine#setMessage(java.lang.String)
|
||||||
* the message is stored and will be shown after a call to clearErrorMessage.
|
|
||||||
*/
|
*/
|
||||||
public void setMessage(String message) {
|
public void setMessage(String message) {
|
||||||
MyMessage temp = new MyImpromptuMessage(INFO, message);
|
MyMessage temp = new MyImpromptuMessage(INFO, message);
|
||||||
pushMessage(temp);
|
setMessage(temp);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/* (non-Javadoc)
|
||||||
* Set the non-error message text, using a SystemMessage object.
|
* @see org.eclipse.rse.ui.messages.ISystemMessageLine#setMessage(org.eclipse.rse.services.clientserver.messages.SystemMessage)
|
||||||
* 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".
|
|
||||||
*/
|
*/
|
||||||
public void setMessage(SystemMessage message) {
|
public void setMessage(SystemMessage message) {
|
||||||
MyMessage temp = new MySystemMessage(message);
|
MyMessage temp = new MySystemMessage(message);
|
||||||
if (temp.isError()) {
|
if (temp.isError()) {
|
||||||
temp = new MyImpromptuMessage(NONE, message.getLevelOneText(), message.getLevelTwoText());
|
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.
|
* Pops a message off the message stack and shows the new top message.
|
||||||
*/
|
*/
|
||||||
private void popMessage() {
|
private void popMessage() {
|
||||||
if (!messageStack.isEmpty()) messageStack.pop();
|
if (!messageStack.isEmpty()) {
|
||||||
|
messageStack.pop();
|
||||||
|
}
|
||||||
showTopMessage();
|
showTopMessage();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -525,8 +566,11 @@ public class SystemMessageLine extends Composite implements ISystemMessageLine {
|
||||||
* @return A MyMessage or null if the stack is empty.
|
* @return A MyMessage or null if the stack is empty.
|
||||||
*/
|
*/
|
||||||
private MyMessage getTopMessage() {
|
private MyMessage getTopMessage() {
|
||||||
if (messageStack.isEmpty()) return null;
|
MyMessage result = null;
|
||||||
return (MyMessage) messageStack.peek();
|
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.
|
* @param message the message from which to get the text.
|
||||||
*/
|
*/
|
||||||
private void setText(MyMessage message) {
|
private void setText(MyMessage message) {
|
||||||
String text = "";
|
String text = ""; //$NON-NLS-1$
|
||||||
String toolTip = null;
|
String toolTip = null;
|
||||||
Color color = null;
|
Color color = null;
|
||||||
if (message != null) {
|
if (message != null) {
|
||||||
|
@ -597,13 +641,13 @@ public class SystemMessageLine extends Composite implements ISystemMessageLine {
|
||||||
if (gc.stringExtent(text).x > maxWidth) {
|
if (gc.stringExtent(text).x > maxWidth) {
|
||||||
StringBuffer head = new StringBuffer(text);
|
StringBuffer head = new StringBuffer(text);
|
||||||
int n = head.length();
|
int n = head.length();
|
||||||
head.append("...");
|
head.append("..."); //$NON-NLS-1$
|
||||||
while (n > 0) {
|
while (n > 0) {
|
||||||
text = head.toString();
|
text = head.toString();
|
||||||
if (gc.stringExtent(text).x <= maxWidth) break;
|
if (gc.stringExtent(text).x <= maxWidth) break;
|
||||||
head.deleteCharAt(--n);
|
head.deleteCharAt(--n);
|
||||||
}
|
}
|
||||||
if (n == 0) text = "";
|
if (n == 0) text = ""; //$NON-NLS-1$
|
||||||
}
|
}
|
||||||
widget.setText(text);
|
widget.setText(text);
|
||||||
}
|
}
|
||||||
|
@ -621,9 +665,9 @@ public class SystemMessageLine extends Composite implements ISystemMessageLine {
|
||||||
Object object = data[i];
|
Object object = data[i];
|
||||||
StringBuffer buffer = new StringBuffer(200);
|
StringBuffer buffer = new StringBuffer(200);
|
||||||
buffer.append(m.getID());
|
buffer.append(m.getID());
|
||||||
buffer.append(": SUB#");
|
buffer.append(": SUB#"); //$NON-NLS-1$
|
||||||
buffer.append(Integer.toString(i));
|
buffer.append(Integer.toString(i));
|
||||||
buffer.append(":");
|
buffer.append(":"); //$NON-NLS-1$
|
||||||
buffer.append(object.toString());
|
buffer.append(object.toString());
|
||||||
logMessage(m.getType(), buffer.toString(), false);
|
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) {
|
private void logMessage(int type, String text, boolean stackTrace) {
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case ERROR:
|
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);
|
SystemBasePlugin.logError(text, e);
|
||||||
break;
|
break;
|
||||||
case WARNING:
|
case WARNING:
|
||||||
|
|
|
@ -259,7 +259,7 @@ public abstract class AbstractSystemWizardPage
|
||||||
// dwd parentComposite = parent;
|
// dwd parentComposite = parent;
|
||||||
Composite myComposite = new Composite(parent, SWT.NONE);
|
Composite myComposite = new Composite(parent, SWT.NONE);
|
||||||
myComposite.setLayout(new GridLayout(1, false));
|
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);
|
myComposite.setLayoutData(gd);
|
||||||
parentComposite = myComposite;
|
parentComposite = myComposite;
|
||||||
Control c = createContents(myComposite);
|
Control c = createContents(myComposite);
|
||||||
|
@ -278,7 +278,6 @@ public abstract class AbstractSystemWizardPage
|
||||||
}
|
}
|
||||||
// dwd configureMessageLine();
|
// dwd configureMessageLine();
|
||||||
msgLine = new SystemMessageLine(myComposite);
|
msgLine = new SystemMessageLine(myComposite);
|
||||||
msgLine.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, true));
|
|
||||||
if (pendingMessage!=null)
|
if (pendingMessage!=null)
|
||||||
setMessage(pendingMessage);
|
setMessage(pendingMessage);
|
||||||
if (pendingErrorMessage!=null)
|
if (pendingErrorMessage!=null)
|
||||||
|
|
Loading…
Add table
Reference in a new issue