blob: 2025e53962bcc98c2325660a5f9638c754381e41 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
|
/*******************************************************************************
* Copyright (c) 2000, 2004 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
*******************************************************************************/
package org.eclipse.ui.texteditor.templates;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.CLabel;
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.jface.resource.JFaceColors;
/**
* A message line displaying a status.
*
* @since 3.0
*/
class MessageLine extends CLabel {
private Color fNormalMsgAreaBackground;
/**
* Creates a new message line as a child of the given parent.
*
* @param parent the parent composite
*/
public MessageLine(Composite parent) {
this(parent, SWT.LEFT);
}
/**
* Creates a new message line as a child of the parent and with the given SWT stylebits.
*
* @param parent the parent composite
* @param style the style
*/
public MessageLine(Composite parent, int style) {
super(parent, style);
fNormalMsgAreaBackground= getBackground();
}
private Image findImage(IStatus status) {
if (status.isOK()) {
return null;
}
return null;
}
/**
* Sets the message and image to the given status.
* <code>null</code> is a valid argument and will set the empty text and no image
*
* @param status the status
*/
public void setErrorStatus(IStatus status) {
if (status != null && !status.isOK()) {
String message= status.getMessage();
if (message != null && message.length() > 0) {
setText(message);
setImage(findImage(status));
setBackground(JFaceColors.getErrorBackground(getDisplay()));
return;
}
}
setText(""); //$NON-NLS-1$
setImage(null);
setBackground(fNormalMsgAreaBackground);
}
}
|