Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » GEF » How to draw the Draw2D diagrams for plain multi-page editors?
How to draw the Draw2D diagrams for plain multi-page editors? [message #221033] Wed, 09 August 2006 01:14 Go to next message
Eclipse UserFriend
Originally posted by: zouzhile.gmail.com

Hi, i am programming a multi-editor, and i want one of its pages to to
display a Draw2D diagram. Each page for the editor is a composite, so
the problem means that how to draw a Draw2D diagram within a composite.

Best Regards:)
Robin
Re: How to draw the Draw2D diagrams for plain multi-page editors? [message #221080 is a reply to message #221033] Wed, 09 August 2006 13:12 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: zouzhile.gmail.com

Robin Zou 写道:
> Hi, i am programming a multi-editor, and i want one of its pages to to
> display a Draw2D diagram. Each page for the editor is a composite, so
> the problem means that how to draw a Draw2D diagram within a composite.
>
> Best Regards:)
> Robin
the case is quite similar to the XML Schema editor, there is a source
page,and there is a diagram pages that is used to display the structures
of the current schema and make modifications to it. And my case is even
simpler, I just need to display the figures according to some model objects.

cheers
Robin
Re: How to draw the Draw2D diagrams for plain multi-page editors? [message #221097 is a reply to message #221080] Wed, 09 August 2006 13:28 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: remove-this-pgarbacz.pgs-soft.com.remove.this

Hi,

"Robin Zou" <zouzhile@gmail.com> wrote in message
news:ebcmuk$f80$1@utils.eclipse.org...
> Robin Zou д
Re: How to draw the Draw2D diagrams for plain multi-page editors? [message #221121 is a reply to message #221097] Thu, 10 August 2006 02:50 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: zouzhile.gmail.com

Pawel Garbacz 写道:
> Hi,
>
> "Robin Zou" <zouzhile@gmail.com> wrote in message
> news:ebcmuk$f80$1@utils.eclipse.org...
>> Robin Zou 写道:
>>> Hi, i am programming a multi-editor, and i want one of its pages to to
>>> display a Draw2D diagram. Each page for the editor is a composite, so
>>> the problem means that how to draw a Draw2D diagram within a composite.
>
>> the case is quite similar to the XML Schema editor, there is a source
>> page,and there is a diagram pages that is used to display the structures
>> of the current schema and make modifications to it. And my case is even
>> simpler, I just need to display the figures according to some model
>> objects.
>
> Your objective is to create CTabFolder containing as many CTabItems as you
> like. One of those would show the diagram the other would show other views
> of your data. This is quite simple: create a control (particular viewer
> showing the data in certain mode) and call setControl() on CTabItem. The
> control should have as it's parent the CTabFolder.
>
> Regards,
> Pawel
>
>
Hi, Pawel, i am sorry that i didn't make it clear enough. The problem is
not how to make the editor "muti-page", instead, it is how to show
draw2D diagram in one of the editor page(each page is set as a top level
composite). As to Draw 2D applications, the lightweight system is
associated with a shell, and a top figure is set as its content, then
all the sub figures can be added to the top figure and make a diagram.
However, problems arise when draw a figure in the composite, no
parent/child relationship can be set. I think i must be missing
something, for example, some kind of control has to be added as a child
as the composite, and the added child control can provide the right
place to configure the lightwightSystem and draw the figures; or the
editor page used to draw the diagram should not be a composite at all.
The muti-page eidtors code is something like this:

public class SomeEditor extends MultiPageEditorPart
{
...........................
protected void createPages()
{
createPage0();
createPage1();
createPage2();

}
// the page 2 is used to draw the diagram, here it is associated
// with a top level composite, all contents on page 2 should be its
// children
void createPage2()
{
Composite composite = new Composite(getContainer(), SWT.NONE);
FillLayout layout = new FillLayout();
composite.setLayout(layout);
BindingGraphicsComposite graphicsComposite = new
BindingGraphicsComposite(composite, SWT.NONE);
int index = addPage(composite);
setPageText(index, "Graphics");
}


}

// I want to be able to draw the Draw2D digram in this composite,
// but this code doesn't work, I must have missed something
public class BindingGraphicsComposite extends Composite
{

public BindingGraphicsComposite(Composite parent, int style)
{
super(parent, style);
this.buildingDiagram(parent);
}
private void buildingDiagram(Composite parent)
{
final Label lable= new Label("Press a button!");
Shell shell= parent.getShell();
LightweightSystem lws= new LightweightSystem(shell);
Figure top= new Figure();
top.setLayoutManager(new XYLayout());
lws.setContents(top);

Clickable above= new CheckBox("I am above");
top.add(above, new Rectangle(10,10,80,20));

}
}

any idea?

Best Regards:)
Robin
Re: How to draw the Draw2D diagrams for plain multi-page editors? [message #221151 is a reply to message #221121] Thu, 10 August 2006 06:39 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: remove-this-pgarbacz.pgs-soft.com.remove.this

"Robin Zou" <zouzhile@gmail.com> wrote in message
news:ebe6rc$hk9$1@utils.eclipse.org...
> Pawel Garbacz д
Re: How to draw the Draw2D diagrams for plain multi-page editors? [message #221158 is a reply to message #221151] Thu, 10 August 2006 08:25 Go to previous message
Eclipse UserFriend
Originally posted by: zouzhile.gmail.com

Pawel Garbacz 写道:
> "Robin Zou" <zouzhile@gmail.com> wrote in message
> news:ebe6rc$hk9$1@utils.eclipse.org...
>> Pawel Garbacz 写道:
>>> Hi,
>>>
>>> "Robin Zou" <zouzhile@gmail.com> wrote in message
>>> news:ebcmuk$f80$1@utils.eclipse.org...
>>>> Robin Zou 写道:
>>>>> Hi, i am programming a multi-editor, and i want one of its pages to to
>>>>> display a Draw2D diagram. Each page for the editor is a composite, so
>>>>> the problem means that how to draw a Draw2D diagram within a composite.
>>>> the case is quite similar to the XML Schema editor, there is a source
>>>> page,and there is a diagram pages that is used to display the structures
>>>> of the current schema and make modifications to it. And my case is even
>>>> simpler, I just need to display the figures according to some model
>>>> objects.
>>> Your objective is to create CTabFolder containing as many CTabItems as
>>> you
>>> like. One of those would show the diagram the other would show other
>>> views
>>> of your data. This is quite simple: create a control (particular viewer
>>> showing the data in certain mode) and call setControl() on CTabItem. The
>>> control should have as it's parent the CTabFolder.
>>>
>>> Regards,
>>> Pawel
>>>
>>>
>> Hi, Pawel, i am sorry that i didn't make it clear enough. The problem is
>> not how to make the editor "muti-page", instead, it is how to show
>> draw2D diagram in one of the editor page(each page is set as a top level
>> composite). As to Draw 2D applications, the lightweight system is
>> associated with a shell, and a top figure is set as its content, then
>> all the sub figures can be added to the top figure and make a diagram.
>> However, problems arise when draw a figure in the composite, no
>> parent/child relationship can be set. I think i must be missing
>> something, for example, some kind of control has to be added as a child
>> as the composite, and the added child control can provide the right
>> place to configure the lightwightSystem and draw the figures; or the
>> editor page used to draw the diagram should not be a composite at all.
>> The muti-page eidtors code is something like this:
>>
>> public class SomeEditor extends MultiPageEditorPart
>> {
>> ...........................
>> protected void createPages()
>> {
>> createPage0();
>> createPage1();
>> createPage2();
>>
>> }
>> // the page 2 is used to draw the diagram, here it is associated
>> // with a top level composite, all contents on page 2 should be its
>> // children
>> void createPage2()
>> {
>> Composite composite = new Composite(getContainer(), SWT.NONE);
>> FillLayout layout = new FillLayout();
>> composite.setLayout(layout);
>> BindingGraphicsComposite graphicsComposite = new
>> BindingGraphicsComposite(composite, SWT.NONE);
>> int index = addPage(composite);
>> setPageText(index, "Graphics");
>> }
>>
>>
>> }
>>
>> // I want to be able to draw the Draw2D digram in this composite,
>> // but this code doesn't work, I must have missed something
>> public class BindingGraphicsComposite extends Composite
>> {
>>
>> public BindingGraphicsComposite(Composite parent, int style)
>> {
>> super(parent, style);
>> this.buildingDiagram(parent);
>> }
>> private void buildingDiagram(Composite parent)
>> {
>> final Label lable= new Label("Press a button!");
>> Shell shell= parent.getShell();
>> LightweightSystem lws= new LightweightSystem(shell);
>> Figure top= new Figure();
>> top.setLayoutManager(new XYLayout());
>> lws.setContents(top);
>>
>> Clickable above= new CheckBox("I am above");
>> top.add(above, new Rectangle(10,10,80,20));
>>
>> }
>> }
>
> Actually when I was using diagram viewer I was not using the
> LightweightSystem directly but wrapped with GraphicalViewer. You can create
> a GraphicalViewer inside any container you should only give the method that
> creates the viewer the right container - and it should not be a Shell but
> also can be a Composite.
>
> By the way I looked into the sources of LightweightSystem class and I saw
> that it does not need a Shell, just a Canvas. GraphicalViewer class will
> create such Canvas called FigureCanvas and will draw on this surface. And
> this Canvas is created as a child of any Composite. The best GraphicalViewer
> implementation for my purposes is ScrollingGraphicalViewer - I even extended
> its functionality.
>
> Maybe this would help.
>
> Regards,
> Pawel
>
>
Hi, Pawel, your suggestion works, thanks you so much for your help!

Have a very nice day!
Robin
Previous Topic:DND Source on PaletteViewer
Next Topic:Special border problem: Problems detecting when a figure goes outside the screen.
Goto Forum:
  


Current Time: Thu Mar 28 15:42:08 GMT 2024

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

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

Back to the top