blob: 3b1cd8d9e8ca09db00451945066bda703843ef57 (
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
|
/*******************************************************************************
* Copyright (c) 2004 - 2006 Mylar committers and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*******************************************************************************/
package org.eclipse.mylyn.internal.tasks.ui;
import org.eclipse.swt.graphics.GC;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.ui.forms.widgets.Hyperlink;
/**
* Override Hyperlink to truncate its text at the end, rather than the middle.
*
* @author Leo Dos Santos
*/
public class TaskListHyperlink extends Hyperlink {
public TaskListHyperlink(Composite parent, int style) {
super(parent, style);
}
// From PerspectiveBarContributionItem
// @Override
protected String shortenText(GC gc, String t, int width) {
if (t == null) {
return null;
}
String returnText = t;
if (gc.textExtent(t).x > width) {
for (int i = t.length(); i > 0; i--) {
String test = t.substring(0, i);
test = test + "...";
if (gc.textExtent(test).x < width) {
returnText = test;
break;
}
}
}
return returnText;
}
}
|