Lines 44-56
Link Here
|
44 |
* Creates a new status line label. |
44 |
* Creates a new status line label. |
45 |
* @param parent parent control |
45 |
* @param parent parent control |
46 |
* @param style the swt style bits |
46 |
* @param style the swt style bits |
|
|
47 |
* @param numOfChars the maximum number of characters this label can |
48 |
* show |
47 |
*/ |
49 |
*/ |
48 |
public StatusLineLabel(Composite parent, int style) { |
50 |
public StatusLineLabel(Composite parent, int style, int numOfChars) { |
49 |
super(parent, style); |
51 |
super(parent, style); |
50 |
|
52 |
|
|
|
53 |
char[] chs = new char[numOfChars]; |
54 |
|
55 |
for (int i = numOfChars - 1; i >= 0; i--) |
56 |
chs[i] = 'M'; |
57 |
|
51 |
GC gc= new GC(parent); |
58 |
GC gc= new GC(parent); |
52 |
gc.setFont(parent.getFont()); |
59 |
gc.setFont(parent.getFont()); |
53 |
Point extent= gc.textExtent("MMMMMMMMM"); //$NON-NLS-1$ |
60 |
Point extent= gc.textExtent(new String(chs)); //$NON-NLS-1$ |
54 |
gc.dispose(); |
61 |
gc.dispose(); |
55 |
|
62 |
|
56 |
fFixedSize= new Point(extent.x + INDENT * 2, 10); |
63 |
fFixedSize= new Point(extent.x + INDENT * 2, 10); |
Lines 71-83
Link Here
|
71 |
/** The status line label widget */ |
78 |
/** The status line label widget */ |
72 |
private StatusLineLabel fLabel; |
79 |
private StatusLineLabel fLabel; |
73 |
|
80 |
|
|
|
81 |
/** The number of characters this status line contribution will show. */ |
82 |
private int fNumOfChars; |
83 |
|
84 |
/** Default: 9 characters will be shown. */ |
85 |
private static int DEFAULT_NUM_OF_CHARS = 9; |
86 |
|
74 |
/** |
87 |
/** |
75 |
* Creates a new item with the given id. |
88 |
* Creates a new item with the given id. |
76 |
* |
89 |
* |
77 |
* @param id the item's id |
90 |
* @param id the item's id |
78 |
*/ |
91 |
*/ |
79 |
public StatusLineContributionItem(String id) { |
92 |
public StatusLineContributionItem(String id) { |
|
|
93 |
this(id, DEFAULT_NUM_OF_CHARS); |
94 |
} |
95 |
|
96 |
/** |
97 |
* Creates a new item with the given id and number of characters to be |
98 |
* shown. |
99 |
* |
100 |
* @param id the item's id |
101 |
* @param numOfChars the maximum number of characters this lable can show |
102 |
* @since 2.1 |
103 |
* |
104 |
*/ |
105 |
public StatusLineContributionItem(String id, int numOfChars) { |
80 |
super(id); |
106 |
super(id); |
|
|
107 |
|
108 |
fNumOfChars= (numOfChars < 1) ? DEFAULT_NUM_OF_CHARS : numOfChars; |
81 |
} |
109 |
} |
82 |
|
110 |
|
83 |
/* |
111 |
/* |
Lines 104-110
Link Here
|
104 |
* @see IContributionItem#fill(Composite) |
132 |
* @see IContributionItem#fill(Composite) |
105 |
*/ |
133 |
*/ |
106 |
public void fill(Composite parent) { |
134 |
public void fill(Composite parent) { |
107 |
fLabel= new StatusLineLabel(parent, SWT.SHADOW_IN); |
135 |
fLabel= new StatusLineLabel(parent, SWT.SHADOW_IN, fNumOfChars); |
108 |
fLabel.setData(this); |
136 |
fLabel.setData(this); |
109 |
|
137 |
|
110 |
if (fText != null) |
138 |
if (fText != null) |