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 BeckerWdf committed Feb 22, 2024
1 parent e630919 commit 6b572cf
Showing 1 changed file with 17 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
*******************************************************************************/
package org.eclipse.e4.ui.workbench.renderers.swt;

import jakarta.inject.Inject;
import java.lang.reflect.Field;
import java.util.Arrays;
import java.util.Objects;
Expand All @@ -27,7 +28,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 @@ -166,6 +171,9 @@ public boolean isTop() {

private boolean drawCustomTabContentBackground;

@Inject
private EModelService eModelService;

public CTabRendering(CTabFolder parent) {
super(parent);
parentWrapper = new CTabFolderWrapper(parent);
Expand Down Expand Up @@ -1330,7 +1338,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 6b572cf

Please sign in to comment.