开发者

How to set size of FolderLayout as absolute value not ratio

I am developing RCP application and I have a problem of defining size of FolderLayout in perspective. As the API requires me to set size as ratio, the size of folder keep changi开发者_运维知识库ng when I manually resize workbench. Is there a way to set absolute size or maximum size of folder layout? It will be like Package explorer view of Java perspecitve in Eclipse that its width will not change when we expand or shorten main workbench size.

Thanks,


You need to respond to ISizeProvider adapter in your ViewPart as in the code below:

public Object getAdapter(Class adapter) {
    if (ISizeProvider.class == adapter) {
        return new ISizeProvider() {
            public int getSizeFlags(boolean width) {
                return SWT.MIN | SWT.MAX | SWT.FILL;
            }

            public int computePreferredSize(boolean width, int availableParallel, int availablePerpendicular, int preferredResult) {
                return width ? 600 : preferredResult;
            }
        };
    }
    return super.getAdapter(adapter);
}

That will make a view to be fixed by width and let height be flexible. For fixed height replace preferedResult with a desired value.

Also note, that moving that part to another view stack folder that already contains other view parts may eliminate fixed size effect, so it makes sense to make the view part unmovable as well [IViewLayout.setMoveable(boolean)]

Cheers, Max

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜