Logic editor description - Using ContainerPolicy [message #225288] |
Sun, 29 October 2006 20:59 |
Eclipse User |
|
|
|
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 #225396 is a reply to message #225296] |
Mon, 30 October 2006 20:58 |
Eclipse User |
|
|
|
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 |
Xiang Qinxian 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 #225596 is a reply to message #225577] |
Tue, 31 October 2006 18:26 |
Xiang Qinxian 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 |
Eclipse User |
|
|
|
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 |
Xiang Qinxian 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 #225859 is a reply to message #225749] |
Thu, 02 November 2006 20:41 |
Eclipse User |
|
|
|
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 |
Eclipse User |
|
|
|
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
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.06263 seconds