Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-SymbolicName: org.eclipse.e4.ui.workbench.addons.swt;singleton:=true
Bundle-Version: 1.6.0.qualifier
Bundle-Version: 1.6.100.qualifier
Bundle-Name: %pluginName
Bundle-Vendor: %providerName
Bundle-Localization: plugin
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@
import java.util.stream.Stream;
import org.eclipse.e4.ui.internal.workbench.swt.AbstractPartRenderer;
import org.eclipse.e4.ui.model.application.ui.MUIElement;
import org.eclipse.e4.ui.model.application.ui.advanced.MPerspective;
import org.eclipse.e4.ui.model.application.ui.advanced.MPlaceholder;
import org.eclipse.e4.ui.model.application.ui.basic.MPart;
import org.eclipse.e4.ui.model.application.ui.basic.MPartStack;
import org.eclipse.e4.ui.model.application.ui.basic.MStackElement;
import org.eclipse.e4.ui.model.application.ui.basic.MWindow;
Expand All @@ -38,6 +40,9 @@
* This agent manage drag and drop when dragging a Tab in Eclipse Part Stacks.
*/
public class StackDropAgent extends DropAgent {
private static final String PERSPECTIVE_SCOPED_OWNER_ID =
"org.eclipse.ui.workbench.viewInSharedAreaOwnerPerspectiveId"; //$NON-NLS-1$

private Rectangle tabArea;
private MPartStack dropStack;
private CTabFolder dropCTF;
Expand Down Expand Up @@ -242,6 +247,7 @@ private void dock(MUIElement dragElement, int dropIndex) {

List<CTabItem> vItems = getVisibleItems(dropCTF);
boolean hiddenTabs = (vItems.size() < dropCTF.getChildren().length);
List<MStackElement> movedElements = new ArrayList<>();

// Adjust the index if necessary
List<MStackElement> dropChildren = dropStack.getChildren();
Expand Down Expand Up @@ -343,6 +349,7 @@ private void dock(MUIElement dragElement, int dropIndex) {
} else {
dropChildren.add((MStackElement) dragElement);
}
movedElements.add((MStackElement) dragElement);

// Bug 410164: remove placeholder element with same id from the drop stack to
// avoid duplicated elements in same stack
Expand Down Expand Up @@ -374,6 +381,7 @@ private void dock(MUIElement dragElement, int dropIndex) {
} else {
dropChildren.add(kid);
}
movedElements.add(kid);
}

// Finally, move over the selected element
Expand All @@ -384,10 +392,48 @@ private void dock(MUIElement dragElement, int dropIndex) {
} else {
dropChildren.add(curSel);
}
movedElements.add(curSel);

// (Re)active the element being dropped
dropStack.setSelectedElement(curSel);
}

updatePerspectiveScopeForMovedViews(movedElements);
}

private void updatePerspectiveScopeForMovedViews(List<MStackElement> movedElements) {
EModelService modelService = dndManager.getModelService();
boolean droppedInSharedArea = modelService.getElementLocation(dropStack) == EModelService.IN_SHARED_AREA;
String activePerspectiveId = null;
if (droppedInSharedArea) {
MWindow window = modelService.getTopLevelWindowFor(dropStack);
if (window != null) {
MPerspective activePerspective = modelService.getActivePerspective(window);
if (activePerspective != null) {
activePerspectiveId = activePerspective.getElementId();
}
}
}

for (MStackElement movedElement : movedElements) {
MUIElement trackedElement = movedElement;
if (movedElement instanceof MPlaceholder placeholder && placeholder.getRef() instanceof MPart part) {
if (part.getTags().contains("Editor")) { //$NON-NLS-1$
continue;
}
trackedElement = placeholder;
} else if (movedElement instanceof MPart part) {
if (part.getTags().contains("Editor")) { //$NON-NLS-1$
continue;
}
}

if (droppedInSharedArea && activePerspectiveId != null) {
trackedElement.getPersistedState().put(PERSPECTIVE_SCOPED_OWNER_ID, activePerspectiveId);
} else {
trackedElement.getPersistedState().remove(PERSPECTIVE_SCOPED_OWNER_ID);
}
}
}

private void showFrame(MUIElement dragElement) {
Expand Down
2 changes: 1 addition & 1 deletion bundles/org.eclipse.e4.ui.workbench/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-SymbolicName: org.eclipse.e4.ui.workbench;singleton:=true
Bundle-Version: 1.18.200.qualifier
Bundle-Version: 1.18.300.qualifier
Bundle-Name: %pluginName
Bundle-Vendor: %providerName
Bundle-Localization: plugin
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,8 @@
public class ModelServiceImpl implements EModelService {

static String HOSTED_ELEMENT = "HostedElement"; //$NON-NLS-1$
private static final String PERSPECTIVE_SCOPED_OWNER_ID =
"org.eclipse.ui.workbench.viewInSharedAreaOwnerPerspectiveId"; //$NON-NLS-1$

private final IEclipseContext appContext;

Expand Down Expand Up @@ -917,6 +919,10 @@ private void resetPerspectiveModel(MPerspective persp, MWindow window,
// Strip out the placeholders in visible stacks
List<MPlaceholder> phList = findElements(area, null, MPlaceholder.class, null);
for (MPlaceholder ph : phList) {
String ownerPerspectiveId = ph.getPersistedState().get(PERSPECTIVE_SCOPED_OWNER_ID);
if (ownerPerspectiveId != null && !ownerPerspectiveId.equals(persp.getElementId())) {
continue;
}
ps.hidePart((MPart) ph.getRef());
ph.getParent().getChildren().remove(ph);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,8 @@
public class WorkbenchPage implements IWorkbenchPage {

private static final String ATT_AGGREGATE_WORKING_SET_ID = "aggregateWorkingSetId"; //$NON-NLS-1$
private static final String PERSPECTIVE_SCOPED_OWNER_ID =
"org.eclipse.ui.workbench.viewInSharedAreaOwnerPerspectiveId"; //$NON-NLS-1$

private static final int WINDOW_SCOPE = EModelService.OUTSIDE_PERSPECTIVE | EModelService.IN_ANY_PERSPECTIVE
| EModelService.IN_SHARED_AREA;
Expand Down Expand Up @@ -2920,6 +2922,7 @@ private List<MPartStack> getPartStacks(MPerspective perspective) {
MPerspective oldPersp = (MPerspective) event.getProperty(UIEvents.EventTags.OLD_VALUE);
MPerspective newPersp = (MPerspective) event.getProperty(UIEvents.EventTags.NEW_VALUE);
// updatePerspectiveActionSets(oldPersp, newPersp);
updatePerspectiveScopedSharedViews(newPersp);

// ((CoolBarToTrimManager)
// legacyWindow.getCoolBarManager2()).updateAll(true);
Expand Down Expand Up @@ -2980,6 +2983,51 @@ private List<MPartStack> getPartStacks(MPerspective perspective) {
legacyWindow.updateActionSets();
};

private void updatePerspectiveScopedSharedViews(MPerspective activePerspective) {
String activePerspectiveId = activePerspective == null ? null : activePerspective.getElementId();

List<MPlaceholder> sharedPlaceholders = modelService.findElements(window, null, MPlaceholder.class, null,
EModelService.OUTSIDE_PERSPECTIVE | EModelService.IN_SHARED_AREA);
for (MPlaceholder placeholder : sharedPlaceholders) {
String ownerPerspectiveId = placeholder.getPersistedState().get(PERSPECTIVE_SCOPED_OWNER_ID);
if (ownerPerspectiveId == null) {
continue;
}
boolean shouldRender = ownerPerspectiveId.equals(activePerspectiveId);
placeholder.setToBeRendered(shouldRender);
updateContainerVisibility(placeholder.getParent());
}

List<MPart> sharedParts = modelService.findElements(window, null, MPart.class, null,
EModelService.OUTSIDE_PERSPECTIVE | EModelService.IN_SHARED_AREA);
for (MPart part : sharedParts) {
if (part.getCurSharedRef() != null) {
continue;
}
String ownerPerspectiveId = part.getPersistedState().get(PERSPECTIVE_SCOPED_OWNER_ID);
if (ownerPerspectiveId == null) {
continue;
}
boolean shouldRender = ownerPerspectiveId.equals(activePerspectiveId);
part.setToBeRendered(shouldRender);
updateContainerVisibility(part.getParent());
}
Comment on lines +2986 to +3014
}

private void updateContainerVisibility(MElementContainer<?> parent) {
if (parent == null) {
return;
}
for (Object child : parent.getChildren()) {
if (child instanceof MUIElement element && element.isVisible() && element.isToBeRendered()) {
parent.setToBeRendered(true);
return;
}
}
parent.setToBeRendered(false);
updateContainerVisibility(parent.getParent());
Comment on lines +3027 to +3028
}

/**
* See IWorkbenchPage.
*/
Expand Down
Loading