Skip to content

Commit

Permalink
Improve 'EditorStack' detection in CTabRendering
Browse files Browse the repository at this point in the history
Enhance tab identification by including a check for tabs located within
the editor area, even when the 'EditorStack' tag is absent.
  • Loading branch information
praveen-skp authored and merks committed Feb 23, 2024
1 parent e630919 commit e0d5976
Showing 1 changed file with 13 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,11 @@
import org.eclipse.core.runtime.preferences.InstanceScope;
import org.eclipse.e4.ui.internal.css.swt.ICTabRendering;
import org.eclipse.e4.ui.internal.workbench.swt.AbstractPartRenderer;
import org.eclipse.e4.ui.model.application.ui.MContext;
import org.eclipse.e4.ui.model.application.ui.MUIElement;
import org.eclipse.e4.ui.workbench.modeling.EModelService;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.util.EcoreUtil;
import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.CTabFolder;
import org.eclipse.swt.custom.CTabFolderRenderer;
Expand Down Expand Up @@ -89,8 +93,6 @@ public class CTabRendering extends CTabFolderRenderer implements ICTabRendering,
private static int MIN_VIEW_CHARS = 1;
private static int MAX_VIEW_CHARS = 9999;

private static final String EditorTag = "EditorStack"; //$NON-NLS-1$

// Constants for circle drawing
static enum CirclePart {
LEFT_TOP, LEFT_BOTTOM, RIGHT_TOP, RIGHT_BOTTOM;
Expand Down Expand Up @@ -1330,7 +1332,15 @@ private IEclipsePreferences getSwtRendererPreferences() {

private boolean isPartOfEditorStack() {
MUIElement element = (MUIElement) parent.getData(AbstractPartRenderer.OWNING_ME);
return element != null && element.getTags().contains(EditorTag);
EObject root = EcoreUtil.getRootContainer((EObject) element, true);
if (root instanceof MContext context) {
EModelService eModelService = context.getContext().get(EModelService.class);
if (eModelService != null) {
int location = eModelService.getElementLocation(element);
return (location & EModelService.IN_SHARED_AREA) != 0;
}
}
return false;
}

private boolean getHideIconsForViewTabsPreference() {
Expand Down

0 comments on commit e0d5976

Please sign in to comment.