Skip to main content



      Home
Home » Newcomers » Newcomers » Determined size of ViewSite(How can the size of a view site be determined)
Determined size of ViewSite [message #1712682] Tue, 27 October 2015 09:26 Go to next message
Eclipse UserFriend
I try to optimize the components of a view part. Therefore, I need to determined the size of the containing view site (IViewSite). Is there a way to determined the size (heigth and width) of a view site?
Re: Determined size of ViewSite [message #1712865 is a reply to message #1712682] Wed, 28 October 2015 18:21 Go to previous messageGo to next message
Eclipse UserFriend
Is there a reason you're not getting it from your view part control?
Re: Determined size of ViewSite [message #1712954 is a reply to message #1712865] Thu, 29 October 2015 10:36 Go to previous message
Eclipse UserFriend
The ViewPart adjusts its size to the components that are contained in it. Therefore, if I request the size of the ViewPart it returns the size the added components, but not the size I could use without having Scrollbars in the ViewPart.

I try to explain this with a small example:
Usually, I use the GridLayout for the creation of the part control. For some components I set the width hint (i.e., layoutData.widthHint = 200), for others I use GridData.FILL_HORIZONTAL. After calling pack() on the parent composite, the ViewPart has an overall width that corresponds to the added widthHints and sizes of the contained components, no matter how big the ViewSite ist.

The following code returns just the size of the Label (defined by the word "Summary") plus the width hint of 200 and some margins. This size will be the same no matter how big the IViewSite is.

public void createPartControl(Composite parent) {
GridLayout layout = new GridLayout();
layout.numColumns = 2;
parent.setLayout(layout);
new Label(parent, SWT.NONE).setText("Summary");
Text text = new Text(parent, SWT.BORDER);
GridData layoutData = new GridData();
layoutData.widthHint = 200;
text.setLayoutData(layoutData);
}

If the widthHint ist not set for the text, the text widget will be very small, if no text is included bevor the pack(). Therefore, it would be very helpfull to know the size of the view site when the content of the view part changes as I could adjust the width hint accordingly and resize the text widget.
Previous Topic:eclipse error
Next Topic:Web Services Explorer Issues
Goto Forum:
  


Current Time: Wed May 07 08:27:17 EDT 2025

Powered by FUDForum. Page generated in 0.30827 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top