Skip to content

Commit

Permalink
Hide ExpandableNode from client's label provider.
Browse files Browse the repository at this point in the history
Unsafe(No type check before accessing passed model element) client's
label provider can lead to ClassCastException. So we can never pass
ExpandableNode to client's label provider.

see eclipse-platform#1353
  • Loading branch information
raghucssit authored and iloveeclipse committed Nov 30, 2023
1 parent 91d17af commit 3d5ae3d
Showing 1 changed file with 7 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -138,17 +138,16 @@ public void setEditingSupport(EditingSupport editingSupport) {
Assert.isTrue(false, "Column " + cell.getColumnIndex() + //$NON-NLS-1$
" has no label provider."); //$NON-NLS-1$
}
labelProvider.update(cell);

// check if client has updated the label for this element. Otherwise use default
// label provided
// Set font and label for ExpandableNode. Client label provider should not
// receive it.
if (cell.getElement() instanceof ExpandableNode expNode) {
cell.setFont(JFaceResources.getFontRegistry().getItalic(JFaceResources.DEFAULT_FONT));
String text = cell.getText();
if (text.isEmpty() || text.equals(expNode.toString())) {
cell.setText(expNode.getLabel());
}
cell.setText(expNode.getLabel());
return;
}

labelProvider.update(cell);

}

/**
Expand Down

0 comments on commit 3d5ae3d

Please sign in to comment.