Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Platform » Help with EditorPart Layout
Help with EditorPart Layout [message #309237] Thu, 19 October 2006 16:14 Go to next message
Eclipse UserFriend
Originally posted by: chlache.talita.org

This code works fine with a ViewPart:

public void createPartControl(Composite parent) {

GridData gridData = new GridData();
gridData.grabExcessHorizontalSpace = true;
gridData.horizontalAlignment = GridData.FILL;
gridData.verticalAlignment = GridData.FILL;
gridData.grabExcessVerticalSpace = true;

parent.setLayout(new GridLayout());

imageCanvas=new ImageCanvas(parent);
imageCanvas.setLayoutData(gridData);
}

But in an EditorPart imageCanvas(extends Canvas).getSize is always==0;
NOT painting anything!
If I call imageCanvas.setSize(300,300) it paints fine within the
specified bounds.
Of course i have tried FillLayout with no success.

Can please someone tell me what i am missing!
Re: Help with EditorPart Layout [message #309238 is a reply to message #309237] Thu, 19 October 2006 16:38 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: chlache.talita.org

Ok found it.
Kind of.
loading the image in init() solves the problem.

Andreas Chlache wrote:
> This code works fine with a ViewPart:
>
> public void createPartControl(Composite parent) {
>
> GridData gridData = new GridData();
> gridData.grabExcessHorizontalSpace = true;
> gridData.horizontalAlignment = GridData.FILL;
> gridData.verticalAlignment = GridData.FILL;
> gridData.grabExcessVerticalSpace = true;
>
> parent.setLayout(new GridLayout());
>
> imageCanvas=new ImageCanvas(parent);
> imageCanvas.setLayoutData(gridData);
> }
>
> But in an EditorPart imageCanvas(extends Canvas).getSize is always==0;
> NOT painting anything!
> If I call imageCanvas.setSize(300,300) it paints fine within the
> specified bounds.
> Of course i have tried FillLayout with no success.
>
> Can please someone tell me what i am missing!
Re: Help with EditorPart Layout [message #309245 is a reply to message #309237] Thu, 19 October 2006 23:58 Go to previous message
Paul Webster is currently offline Paul WebsterFriend
Messages: 6859
Registered: July 2009
Location: Ottawa
Senior Member

Andreas Chlache wrote:
> This code works fine with a ViewPart:
>
> public void createPartControl(Composite parent) {
>
> GridData gridData = new GridData();
> gridData.grabExcessHorizontalSpace = true;
> gridData.horizontalAlignment = GridData.FILL;
> gridData.verticalAlignment = GridData.FILL;
> gridData.grabExcessVerticalSpace = true;
>
> parent.setLayout(new GridLayout());


^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Please never do this (there's probably some bad example code out there
that keeps getting propogated forward). The parent composite in
ViewPart and EditorPart is not for clients to reset the layout on.

Always create your own composite to control your part layout.

Composite x = new Composite(parent, SWT.NONE);

//...

x.setLayout(new GridLayout());


Previous Topic:Help with FormText/ScrolledFormText
Next Topic:How to close editor when Project is closed
Goto Forum:
  


Current Time: Fri Apr 19 20:48:31 GMT 2024

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

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

Back to the top