I have an application that I am building in in e4 but am having trouble getting a couple parts to be a fixed size. I have a PartSashContainer
with two Parts
and another PartSashContainer
in it. I initially set size in the containerData
parameter, but these values are relative and still allow for re-sizing of the parts. I want to make sure these parts are a fixed height and can not be re-sized. Is there an easy way of doing this?
Eclipse bug 361731 is a request for this feature. Currently it has not been implemented.
It might be possible to do with a custom renderer, but this is hard work.
我不确定在Neon之前是否可以使用此功能,但是Eclipse Neon允许您将“ NoMove”作为标签添加到要锁定且不调整大小的Part Sash Container
框格Part Sash Container
中。
I had a very similar task and stumbled across your question several times. I need to implement a RCP application, following a Corporate Design with a fixed size application header and a fixed size footer. I found no perfect way, but the vogella tutorial on custom renderers gave me some hints. I still had to duplicate some code, I didn't find a clever way around.
My requirements:
So what I did was:
public class MainWorkbenchRendererFactory extends WorkbenchRendererFactory {
private final static String MAIN_SASH_ID = "myapp.partsashcontainer.main";
@Override
public AbstractPartRenderer getRenderer(MUIElement uiElement, Object parent) {
if (uiElement instanceof MPartSashContainer
&& MAIN_SASH_ID.equalsIgnoreCase(((MPartSashContainer)uiElement).getElementId())) {
MainSashRenderer renderer = new MainSashRenderer();
super.initRenderer(renderer);
return renderer;
}
return super.getRenderer(uiElement, parent);
}
}
In class "MainSashRenderer", change reference from "SashLayout" to "MainSashLayout".
In class "MainSashLayout", method tileSubNodes:
// subsctract size for header and footer:
availableSpace -= (this.footerHeightPx + this.headerHeightPx);
// Subtract off the room for the sashes
availableSpace -= ((childCount - 1) * sashWidth);
if (availableSpace < 0)
availableSpace = 0;
for (MUIElement subNode : visibleChildren) {
if (childNum == 0) {
newSize = this.headerHeightPx;
} else if (childNum == visibleChildren.size()-1) {
newSize = this.footerHeightPx;
} else {
// Calc the new size as a %'age of the total
double ratio = getWeight(subNode) / totalWeight;
newSize = (int) ((availableSpace * ratio) + 0.5);
}
...
Result with different window sizes (header and footer keep their pixel height): Screenshots with different window sizes
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.