Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » GEF » Logic editor description - Using ContainerPolicy
Logic editor description - Using ContainerPolicy [message #225288] Sun, 29 October 2006 20:59 Go to next message
Eclipse UserFriend
Originally posted by: xylo3.o2.pl

Where can I find description of Logic Editor example ?
I am especially interested in creating editparts that use
ContainerEditPolicy.
Could anyone describe briefly what should I do to enable one component to
contain another ? I am quite new to GEF ...

Thanks in advance,
Max
Re: Logic editor description - Using ContainerPolicy [message #225296 is a reply to message #225288] Mon, 30 October 2006 09:01 Go to previous messageGo to next message
Xiang Qinxian is currently offline Xiang QinxianFriend
Messages: 119
Registered: July 2009
Senior Member
在 2006-10-29日的 20:59 +0000,Max写道:
> Where can I find description of Logic Editor example ?
> I am especially interested in creating editparts that use
> ContainerEditPolicy.
> Could anyone describe briefly what should I do to enable one component to
> contain another ? I am quite new to GEF ...
>
> Thanks in advance,
> Max
>
Hi,
If download GEF-All*, you had got it.And check it out from you Plug-in
Development Pespective, you will find it.
>From plugin-in view you can select a plugin and right click and select
Import as menu command, and?
get it:)

Regards,

Qinxian
Re: Logic editor description - Using ContainerPolicy [message #225396 is a reply to message #225296] Mon, 30 October 2006 20:58 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: xylo3.o2.pl

Thanks a lot Qinxian
I have looked at the source code, but it does not solve all my problems:
i.e It's still difficult for me to guess meaning of some methods without
familiarising myself with entire project. Could you be so kindly and give
me some further guidelines ( brief description of enabling shape to
contain another node s (like circut in Logic Example does) will be
appreciated much ! ;) ) ?

Can you recommend any articles/guides/howto etc. that describe in details
various policies used in GEF and give a view of GEF good practices ?
I have already studied
http://eclipsewiki.editme.com/GefDescription
but as you can see I still suffer from lack of GEF know-how ...

Best regards,
Max
Re: Logic editor description - Using ContainerPolicy [message #225426 is a reply to message #225396] Tue, 31 October 2006 03:45 Go to previous messageGo to next message
Xiang Qinxian is currently offline Xiang QinxianFriend
Messages: 119
Registered: July 2009
Senior Member
Hi,
在 2006-10-30一的 20:58 +0000,Max写道:
> Thanks a lot Qinxian
> I have looked at the source code, but it does not solve all my problems:
> i.e It's still difficult for me to guess meaning of some methods without
> familiarising myself with entire project. Could you be so kindly and give
> me some further guidelines ( brief description of enabling shape to
> contain another node s (like circut in Logic Example does) will be
> appreciated much ! ;) ) ?
Right, supposed there is a TaskGroup contained Tasks. and its editpart
and figures.
class Task{}
class TaskGroup{
List<Task> children;
List<Task> getChildren();
}
class TaskFigure extends Figure{}
class TaskGroupFigure extends Figure{
FlowLayout layout;
Figure content;
TaskFigure(){
add(content);
setLayoutManager(layout);
}
//more important
IFigure getContentPane(){return content;}
}

TaskGroupEditPart{
IFigure createFigure(){return new TaskGrouFigure();}
getContentPane(){
return TaskGroupFigure.class.cast(getFigure()).getContentPane();}
}
//must according to figure layout install difference editpolicy lyout
role
@Override
createEditPolicy(){
//for testing, this policy can do empty implementation, just inherit it.
installEditPolicy(LAYOUT_ROLE, aFlowLayoutEditPolicy);
}
@Override
List getModelChild(){
//must not null return value.
return TaskGroup.class.cast(getModel()).getChildren();}
}
class TaskEdtiPart{
IFigure createFigue(){return new TaskFigure();}
}

well, that's it. a container outline code. it's enough. all methods
needed to pay attention to just be here. ofcause, you know init these
objects.
>
> Can you recommend any articles/guides/howto etc. that describe in details
> various policies used in GEF and give a view of GEF good practices ?
> I have already studied
> http://eclipsewiki.editme.com/GefDescription
> but as you can see I still suffer from lack of GEF know-how ...
>
> Best regards,
> Max
>

on http://www.eclipse.org/articles/
there is a database schema editor, Maybe you need it.
And there is yet a serials sample, should can be found in wiki. seem be
simple logic or others.

Hope it help.

Regards,

Qinxian
Re: Logic editor description - Using ContainerPolicy [message #225577 is a reply to message #225426] Tue, 31 October 2006 15:51 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: xylo3.o2.pl

Great job Qinxian!
Thanks for your helpful example.
But I still do not know how to use CONTAINER_ROLE ?
Coud you explain it in details to me ?
As usually, your help will be appreciated ;)

Regards,
Max
Re: Logic editor description - Using ContainerPolicy [message #225596 is a reply to message #225577] Tue, 31 October 2006 18:26 Go to previous messageGo to next message
Xiang Qinxian is currently offline Xiang QinxianFriend
Messages: 119
Registered: July 2009
Senior Member
Max 写道:
> Great job Qinxian!
> Thanks for your helpful example.
> But I still do not know how to use CONTAINER_ROLE ?
> Coud you explain it in details to me ?
> As usually, your help will be appreciated ;)
>
> Regards,
> Max
>
Hi,
You are welcome, you happy and I happy.
You can refer to ContainerEditPolicy source code, check out
getCommand(Request) method.
Each EditPolicy must understand passed-in Request, if it do some work.
request include REQ_ORPHAN_CHILDREN, CREATE, ADD, CLONE.
From EditPolicy iterator design, you can use all commands in it.
A simple way to deep into it, override by policy of yourself, log it,
and check it out.

Almost these requests can be understanded by layouteditpolicy subclass.
So, if use it, no matter.In a Graphical Editor, importancy of layout
editpolicy is more that container edit policy.

And it can be use in GEF TreeViewer.

Regards,

Qinxian
Re: Logic editor description - Using ContainerPolicy [message #225670 is a reply to message #225596] Wed, 01 November 2006 16:02 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: xylo3.o2.pl

Thanks for your guidelines!
I give you a brief view of current situation ;) :

I have 2 kind of part ( class of object from model domain), let say :
- Container
- Element

I would like to be able to drop Element into Container ( you can observer
similar behavior for LED and Circuit in Logic Example).

In order to provide this feature I have implemented
- ContainerPolicy for CONTAINER_ROLE
- ContainerLayoutPolicy for LAYOUT_ROLE

It seems that ContainerPolicy is implemented in right way
( I have overriden getAddCommand(GroupRequest req) and it is executed when
I
drop Element figure into Container figure)

I guess that I have to work on my ContainerLayoutPolicy implementation.
Now I have an issue : I can drop Element into Container but when I move
Container, elements that are contained in it do not follow Container ;(

In ContainerLayoutPolicy I have something like that:

protected Command createAddCommand(EditPart child, Object constraint) {
log.debug("add command");
Element element = (Element)child.getModel();
Container container = (Container)getHost().getModel();
Rectangle rect = (Rectangle)constraint;
/*** create command responsible for adding element to container ***/
AddElementToContainerCommand add = new AddElementToContainerCommand
(container);
add.addElement(element);

/*** create command responsible for updating size and locatio view of
Element added to Container ***/
SetConstraintCommand setConstraint = new SetConstraintCommand();
setConstraint.setLocation(rect);
setConstraint.setPart(component);
// setConstraint.setDebugLabel("LogicXYEP setConstraint");//$NON-NLS-1$

Command cmd = add.chain(setConstraint);
return cmd;
}


What is more, AddElementToContainerCommand is used by ContainerPolicy as
well.

Any suggestion will be appreciated ...

Regards,
Max
Re: Logic editor description - Using ContainerPolicy [message #225749 is a reply to message #225670] Wed, 01 November 2006 23:08 Go to previous messageGo to next message
Xiang Qinxian is currently offline Xiang QinxianFriend
Messages: 119
Registered: July 2009
Senior Member
Hi Max,
You do it great yourself.
Max 写道:
>
> Thanks for your guidelines!
> I give you a brief view of current situation ;) :
>
> I have 2 kind of part ( class of object from model domain), let say :
> - Container
> - Element
>
> I would like to be able to drop Element into Container ( you can
> observer similar behavior for LED and Circuit in Logic Example).
>
> In order to provide this feature I have implemented
> - ContainerPolicy for CONTAINER_ROLE
> - ContainerLayoutPolicy for LAYOUT_ROLE
>
> It seems that ContainerPolicy is implemented in right way ( I have
> overriden getAddCommand(GroupRequest req) and it is executed when I drop
> Element figure into Container figure)
>
> I guess that I have to work on my ContainerLayoutPolicy implementation.
> Now I have an issue : I can drop Element into Container but when I move
> Container, elements that are contained in it do not follow Container ;(
>
> In ContainerLayoutPolicy I have something like that:
>
> protected Command createAddCommand(EditPart child, Object constraint) {
> log.debug("add command");
> Element element = (Element)child.getModel();
> Container container = (Container)getHost().getModel();
> Rectangle rect = (Rectangle)constraint;
> /*** create command responsible for adding element to container
> ***/
> AddElementToContainerCommand add = new
> AddElementToContainerCommand (container);
> add.addElement(element);
>
> /*** create command responsible for updating size and
> locatio view of Element added to Container ***/
> SetConstraintCommand setConstraint = new SetConstraintCommand();
> setConstraint.setLocation(rect);
> setConstraint.setPart(component);
> // setConstraint.setDebugLabel("LogicXYEP
> setConstraint");//$NON-NLS-1$
>
> Command cmd = add.chain(setConstraint);
> return cmd;
> }
>
>
> What is more, AddElementToContainerCommand is used by ContainerPolicy as
> well.
From design logic view, any non-group command has only once right
execution in a operation, generally.
Override the container editpart method getCommand(), before and after,
see if there are more commands executed for request.
>
> Any suggestion will be appreciated ...
>
> Regards,
> Max
>
>

Regards,

Qinxian
Re: Logic editor description - Using ContainerPolicy [message #225843 is a reply to message #225670] Thu, 02 November 2006 19:38 Go to previous messageGo to next message
Alex Boyko is currently offline Alex BoykoFriend
Messages: 200
Registered: July 2009
Senior Member
Hi Max,

I have a feeling that elements inside the container shouldn't be touched
at all, when you perform a move or a resize of the container edit part.
Ideally, they are children of container edit part's figure and have
coordinates relative to the parent figure, hence when the container figure
is revalidated children should be drawn inside the container's figure
bounds. Do you still have this problem?

Cheers,
Alex
Re: Logic editor description - Using ContainerPolicy [message #225859 is a reply to message #225749] Thu, 02 November 2006 20:41 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: xylo3.o2.pl

I am stacked in :/
This Logic Example covers to many things at the same time - I don't know
what is important to get required feature :

I have two elements : Box and Subject
I want to obtain in editor following behaviour:
1. I would like to be able to drop existing (already located at the
diagram ) subjects into box.
2.
Re: Logic editor description - Using ContainerPolicy [message #225867 is a reply to message #225749] Thu, 02 November 2006 20:45 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: xylo3.o2.pl

Sorry for double posting ...


I am stacked in :/
This Logic Example covers to many things at the same time - I don't know
what is important to get required feature :

I have two elements : Box and Subject
I want to obtain in editor following behaviour:
1. I would like to be able to drop existing (already located at the
diagram ) subjects into box.
2.I'd like to get subject from box and put back in diagram (reverse action
to the one described above)
3. When I move box I'd like that all subject contained in the box move as
well.

Question:
1. What Policy I have to install in Box and Subject?
2. What methods I have to implement in required policies subclasses?

I hope for your answers :)

Regards,
Max
Re: Logic editor description - Using ContainerPolicy [message #225873 is a reply to message #225867] Thu, 02 November 2006 21:07 Go to previous messageGo to next message
Alex Boyko is currently offline Alex BoykoFriend
Messages: 200
Registered: July 2009
Senior Member
Hi Max,

Perhaps, the problem is not on the edit policies installed, but on the
edit parts. I'd suggest you to check how the figure of a child edit part
is added to the container's figure (figure of BoxEditPart in your case),
namely debug:
org.eclipse.gef.editparts.AbstractGraphicalEditPart#addChild Visual(EditPart
childEditPart, int index) method. Check how the child's figure is added.
In logic example circuit edit part's figure consists of a CircuitBorder
and FreeformLayout figures. The child's figure is added to the content
pane's figure of the circuit edit part, which is a FreeformLayout figure.
Check this, let me know how it goes.

Cheers,
Alex
Re: Logic editor description - Using ContainerPolicy [message #225879 is a reply to message #225867] Thu, 02 November 2006 21:32 Go to previous message
Alex Boyko is currently offline Alex BoykoFriend
Messages: 200
Registered: July 2009
Senior Member
Max,
for my previous comment: also check what's the layout manager on the box
figure.
Previous Topic:Context menu
Next Topic:Global Copy Action not Working
Goto Forum:
  


Current Time: Thu Oct 28 17:53:57 GMT 2021

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

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

Back to the top