2
|
1 |
// Copyright (c) 2009 The Chromium Authors. All rights reserved.
|
|
2 |
// Use of this source code is governed by a BSD-style license that can be
|
|
3 |
// found in the LICENSE file.
|
|
4 |
|
|
5 |
package org.chromium.debug.ui;
|
|
6 |
|
|
7 |
import org.eclipse.core.resources.IFile;
|
|
8 |
import org.eclipse.jface.viewers.ILabelDecorator;
|
|
9 |
import org.eclipse.jface.viewers.ILabelProviderListener;
|
|
10 |
import org.eclipse.swt.graphics.Image;
|
|
11 |
|
|
12 |
/**
|
|
13 |
* A decorator that removes the ".chromium" file extension
|
|
14 |
* in the Project Explorer for the Debug Javascript project files.
|
|
15 |
*/
|
|
16 |
public class ChromiumJavascriptDecorator implements ILabelDecorator {
|
|
17 |
|
|
18 |
public Image decorateImage(Image image, Object element) {
|
|
19 |
return image;
|
|
20 |
}
|
|
21 |
|
|
22 |
public String decorateText(String text, Object element) {
|
|
23 |
// (element instanceof IFile) is guaranteed by the enablement in plugin.xml
|
|
24 |
return getDecoratedText(text, element);
|
|
25 |
}
|
|
26 |
|
|
27 |
/**
|
|
28 |
* @param text the original label of the element
|
|
29 |
* @param element must be an IFile instance
|
|
30 |
* @return a decorated element label, or the original one if the label
|
|
31 |
* need not be decorated or there was a CoreException reading
|
|
32 |
* the element's project natures
|
|
33 |
*/
|
|
34 |
public static String getDecoratedText(String text, Object element) {
|
|
35 |
if (PluginUtil.isChromiumDebugFile((IFile) element)) {
|
|
36 |
return PluginUtil.stripChromiumExtension(text);
|
|
37 |
}
|
|
38 |
return text;
|
|
39 |
}
|
|
40 |
|
|
41 |
public void addListener(ILabelProviderListener listener) {
|
|
42 |
}
|
|
43 |
|
|
44 |
public void dispose() {
|
|
45 |
}
|
|
46 |
|
|
47 |
public boolean isLabelProperty(Object element, String property) {
|
|
48 |
return false;
|
|
49 |
}
|
|
50 |
|
|
51 |
public void removeListener(ILabelProviderListener listener) {
|
|
52 |
}
|
|
53 |
}
|