|
Added
Link Here
|
| 1 |
/******************************************************************************* |
| 2 |
* Copyright (c) 2000, 2007 IBM Corporation and others. |
| 3 |
* All rights reserved. This program and the accompanying materials |
| 4 |
* are made available under the terms of the Eclipse Public License v1.0 |
| 5 |
* which accompanies this distribution, and is available at |
| 6 |
* http://www.eclipse.org/legal/epl-v10.html |
| 7 |
* |
| 8 |
|
| 9 |
*******************************************************************************/ |
| 10 |
package org.eclipse.dltk.ui.viewsupport; |
| 11 |
|
| 12 |
import org.eclipse.dltk.ui.ProblemsLabelDecorator; |
| 13 |
import org.eclipse.jface.viewers.DecoratingStyledCellLabelProvider; |
| 14 |
import org.eclipse.jface.viewers.DecorationContext; |
| 15 |
import org.eclipse.jface.viewers.ILabelProvider; |
| 16 |
import org.eclipse.ui.PlatformUI; |
| 17 |
|
| 18 |
/** |
| 19 |
* a DecoratingModelLabelProvider which support StyledText |
| 20 |
* |
| 21 |
* replace org.eclipse.dltk.ui.viewsupport.StyledDecoratingModelLabelProvider |
| 22 |
* |
| 23 |
* @since 5.1 |
| 24 |
*/ |
| 25 |
public class StyledDecoratingModelLabelProvider extends DecoratingStyledCellLabelProvider implements ILabelProvider { |
| 26 |
|
| 27 |
/** |
| 28 |
* Decorating label provider for DLTK. Combines a ScriptUILabelProvider with |
| 29 |
* problem and override indicuator with the workbench decorator (label |
| 30 |
* decorator extension point). |
| 31 |
*/ |
| 32 |
public StyledDecoratingModelLabelProvider(ScriptUILabelProvider labelProvider) { |
| 33 |
this(labelProvider, true); |
| 34 |
} |
| 35 |
|
| 36 |
/** |
| 37 |
* Decorating label provider for dltk. Combines a ScriptUILabelProvider (if |
| 38 |
* enabled with problem indicator) with the workbench decorator (label |
| 39 |
* decorator extension point). |
| 40 |
*/ |
| 41 |
public StyledDecoratingModelLabelProvider(ScriptUILabelProvider labelProvider, |
| 42 |
boolean errorTick) { |
| 43 |
this(labelProvider, errorTick, true); |
| 44 |
} |
| 45 |
|
| 46 |
/** |
| 47 |
* Decorating label provider for dltk. Combines a ScriptUILabelProvider (if |
| 48 |
* enabled with problem indicator) with the workbench decorator (label |
| 49 |
* decorator extension point). |
| 50 |
*/ |
| 51 |
public StyledDecoratingModelLabelProvider(ScriptUILabelProvider labelProvider, |
| 52 |
boolean errorTick, boolean flatPackageMode) { |
| 53 |
super(labelProvider, PlatformUI.getWorkbench().getDecoratorManager() |
| 54 |
.getLabelDecorator(),null); |
| 55 |
|
| 56 |
if (errorTick) { |
| 57 |
labelProvider.addLabelDecorator(new ProblemsLabelDecorator(null)); |
| 58 |
} |
| 59 |
setFlatPackageMode(flatPackageMode); |
| 60 |
} |
| 61 |
|
| 62 |
/** |
| 63 |
* Tells the label decorator if the view presents packages flat or |
| 64 |
* hierarchical. |
| 65 |
* |
| 66 |
* @param enable |
| 67 |
* If set, packages are presented in flat mode. |
| 68 |
*/ |
| 69 |
public void setFlatPackageMode(boolean enable) { |
| 70 |
if (enable) { |
| 71 |
setDecorationContext(DecorationContext.DEFAULT_CONTEXT); |
| 72 |
} else { |
| 73 |
setDecorationContext(DecorationContext.DEFAULT_CONTEXT); |
| 74 |
// TODO setDecorationContext(HierarchicalDecorationContext.CONTEXT); |
| 75 |
} |
| 76 |
} |
| 77 |
|
| 78 |
public String getText(Object element) { |
| 79 |
return getStyledText(element).toString(); |
| 80 |
} |
| 81 |
} |