Open E1izabeth opened 1 year ago
This is a good proposal. Are you willing to submit a PR that implements it?
I've made some digging into CTabFolder and for me it looks pretty unobvious, what are the required modifications to introduce the functionality under consideration.
In CTabFolder, around line 2080
for (int i=0; i < items.length; i++) {
Rectangle itemBounds = items[i].getBounds();
if (i != selectedIndex && event.getBounds().intersects(itemBounds)) {
renderer.draw(i, SWT.BACKGROUND | SWT.FOREGROUND | items[i].state , itemBounds, gc);
}
}
Is the block that instructs of drawing the tabs. Currently it seems to only care about the position to decide what to draw, but if there are extra infos like "pinned" available, those can be used to take priority when deciding here what to draw or not.
As far as I have seen, the only reference for pinned
is in WorkbenchPartReference
, I don't think checking for pinned is apropriate in CTabFolder. It is likely that the better solution set the priority indexes in the CTabFolder for the pinned elements. I am not yet sure how a WorkbenchPartReference
could find it's own CTabFolder - I will investigate into this. @mickaelistria
Another - possibly cleaner - solution is to add an option for pinning CTabItems in a CTabFolder. I can imagine an API that looks like this (very roughly sketched):
tabFolder.allowForPinning(true);
tabFolder.pin (4);
allowForPinning
could display a tooltip to the CTabFolder
add an option for pinning CTabItems in a CTabFolder
yes, I think that the best place where to hook the low-level capability as it will be able to serve more cases. Although it would only be a subset of the solution: for editors, you'd also need to store somewhere (eg in the memento) which editors/parts are pinned so they remain pinned upon restart.
tabFolder.allowForPinning(true);
tabFolder.pin (4);
You don't need a particular method to enable the feature, just tabFolder.pin(4)
is enough. Then consumers such as the CTabFolderRenderer used by the workbench can take care of adding the pin
context menu as they prefer and call tabFolder.pin(x)
directly, together with related actions (such as storing the state in the workbench).
It would be nice if pin editor tab command moves tab to the left or to a separate toolbar for pinned tabs.
We (DBeaver) have such requests from our community dbeaver/dbeaver#17160 and tried to implement our own command for that, but eclipse platform doesn't have a way to manage editor's icon and override drag-n-drop actions.