我有一个问题可能与eclipse 3.5.1有关。我有一个插件,除了其他东西之外,还为已经更改的文件添加了字符串装饰。在Eclipse 3.7.1中一切正常,但在eclipse 3.5.1上的目标应用程序中,导航器不能正确显示样式字符串。
字符串装饰的代码如下(它还添加了文件版本,这也不适用于eclipse 3.5.1):
public class CustomLabelProvider extends ResourceExtensionLabelProvider implements
org.eclipse.jface.viewers.DelegatingStyledCellLabelProvider.IStyledLabelProvider {
@Override
public StyledString getStyledText(Object element) {
StyledString label = new StyledString();
try {
Set modifiedFiles =
CustomContentProvider.getModifiedSegments().get(
((Resource) element).toString().substring(1));
if ((modifiedFiles != null) && (modifiedFiles.size() > 0)) {
label.append(">", StyledString.DECORATIONS_STYLER);
}
label.append(getText(element));
if (element instanceof ExtendedFile) {
Integer fileVersion = ((ExtendedFile) element).getFileVersion();
if (fileVersion != null) {
label.append(" ").append(fileVersion.toString(), StyledString.DECORATIONS_STYLER);
}
}
} catch (Exception e) {
e.printStackTrace();
}
return label;
}
两个eclipse版本之间的比较:
eclipse 3.5.1和3.7.1都实现了IStyledLabelProvider。该插件在两个eclipse版本中启动,osgi将其列为ACTIVE,并且有一些我删除的日志记录,这在两个eclipse版本中都有效。这种行为可能是什么原因?
更新:标签提供程序plugin.xml
<plugin>
<extension
point="org.eclipse.ui.navigator.viewer">
<viewer
viewerId="myApplication.NavigatorView">
</viewer>
<viewerContentBinding viewerId="myApplication.NavigatorView">
<includes>
<contentExtension pattern="NavigatorLabelProvider.NavigatorContent"/>
</includes>
</viewerContentBinding>
</extension>
<extension
point="org.eclipse.ui.navigator.navigatorContent">
<navigatorContent
name="myNavigatorContent"
activeByDefault="true"
contentProvider="labelprovider.CustomContentProvider"
labelProvider="labelprovider.CustomLabelProvider"
id="NavigatorLabelProvider.NavigatorContent">
<enablement>
<or>
<adapt type="org.eclipse.core.resources.IProject" />
<instanceof
value="org.eclipse.core.resources.IResource" />
</or>
</enablement>
<commonSorter
class="org.eclipse.ui.internal.navigator.resources.workbench.ResourceExtensionSorter"
id="org.eclipse.ui.navigator.resources.sorters.defaultSorter">
<parentExpression>
<or>
<instanceof value="org.eclipse.core.resources.IResource" />
</or>
</parentExpression>
</commonSorter>
<dropAssistant
class="org.eclipse.ui.navigator.resources.ResourceDropAdapterAssistant"
id="org.eclipse.ui.navigator.resources.resourceDropAdapter">
<possibleDropTargets>
<or>
<adapt type="org.eclipse.core.resources.IProject"/>
<adapt type="org.eclipse.core.resources.IFolder"/>
<adapt type="org.eclipse.core.resources.IFile"/>
</or>
</possibleDropTargets>
</dropAssistant>
<actionProvider
class="org.eclipse.ui.internal.navigator.resources.actions.EditActionProvider"
id="org.eclipse.ui.navigator.resources.actions.EditActions"/>
<actionProvider
class="org.eclipse.ui.internal.navigator.resources.actions.RefactorActionProvider"
id="org.eclipse.ui.navigator.resources.actions.RefactorActions"/>
<!-- Menu Shortcut Actions for Wizards -->
<commonWizard
type="new"
wizardId="org.eclipse.ui.wizards.new.folder">
<enablement>
<or>
<adapt type="org.eclipse.core.resources.IFile" />
<adapt type="org.eclipse.core.resources.IFolder" />
<adapt type="org.eclipse.core.resources.IProject" />
<adapt type="org.eclipse.core.resources.IWorkspaceRoot" />
</or>
</enablement>
</commonWizard>
<commonWizard
type="new"
wizardId="org.eclipse.ui.wizards.new.file">
<enablement>
<or>
<adapt type="org.eclipse.core.resources.IFile" />
<adapt type="org.eclipse.core.resources.IFolder" />
<adapt type="org.eclipse.core.resources.IProject" />
<adapt type="org.eclipse.core.resources.IWorkspaceRoot" />
</or>
</enablement>
</commonWizard>
</navigatorContent>
</extension>
</plugin>