use of org.bndtools.utils.jface.HyperlinkStyler in project bndtools by bndtools.
the class RepositoryTreeLabelProvider method update.
@Override
public void update(ViewerCell cell) {
Object element = cell.getElement();
int index = cell.getColumnIndex();
if (element instanceof RepositoryPlugin) {
if (index == 0) {
RepositoryPlugin repo = (RepositoryPlugin) element;
cell.setText(repo.getName());
Image image;
if (RepoUtils.isWorkspaceRepo(repo))
image = projectImg;
else if (isRemoteRepo((RepositoryPlugin) element))
image = remoteRepoImg;
else
image = localRepoImg;
cell.setImage(image);
}
} else if (element instanceof Project) {
if (index == 0) {
@SuppressWarnings("resource") Project project = (Project) element;
StyledString label = new StyledString(project.getName());
if (showRepoId)
label.append(" [Workspace]", StyledString.QUALIFIER_STYLER);
cell.setText(label.getString());
cell.setStyleRanges(label.getStyleRanges());
cell.setImage(projectImg);
}
} else if (element instanceof ProjectBundle) {
if (index == 0) {
StyledString label = new StyledString(((ProjectBundle) element).getBsn());
if (showRepoId)
label.append(" [Workspace]", StyledString.QUALIFIER_STYLER);
cell.setText(label.getString());
cell.setStyleRanges(label.getStyleRanges());
cell.setImage(bundleImg);
}
} else if (element instanceof RepositoryBundle) {
if (index == 0) {
RepositoryBundle bundle = (RepositoryBundle) element;
StyledString label = new StyledString(bundle.getText());
if (showRepoId)
label.append(" [" + bundle.getRepo().getName() + "]", StyledString.QUALIFIER_STYLER);
cell.setText(label.getString());
cell.setStyleRanges(label.getStyleRanges());
cell.setImage(bundleImg);
}
} else if (element instanceof RepositoryBundleVersion) {
if (index == 0) {
RepositoryBundleVersion bundleVersion = (RepositoryBundleVersion) element;
String versionText = bundleVersion.getText();
if (versionText.contains(" ⇩")) {
versionText = versionText.replaceAll(" ⇩", "");
cell.setImage(arrowImg);
}
StyledString styledString = new StyledString(versionText, StyledString.COUNTER_STYLER);
cell.setText(styledString.getString());
cell.setStyleRanges(styledString.getStyleRanges());
}
} else if (element instanceof RepositoryResourceElement) {
RepositoryResourceElement resourceElem = (RepositoryResourceElement) element;
StyledString label = new StyledString();
label.append(resourceElem.getIdentity()).append(" ");
label.append(resourceElem.getVersionString(), StyledString.COUNTER_STYLER);
cell.setText(label.getString());
cell.setStyleRanges(label.getStyleRanges());
cell.setImage(matchImg);
} else if (element instanceof ContinueSearchElement) {
StyledString label = new StyledString("Continue Search on JPM4J.org...", new HyperlinkStyler());
cell.setText(label.getString());
cell.setStyleRanges(label.getStyleRanges());
} else if (element instanceof LoadingContentElement) {
cell.setText("Loading content...");
cell.setImage(loadingImg);
} else if (element != null) {
// Catch-all
cell.setText(element.toString());
}
}
Aggregations