Logic editor description - Using ContainerPolicy [message #225288] |
Sun, 29 October 2006 15: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 #225426 is a reply to message #225396] |
Mon, 30 October 2006 22:45   |
Eclipse User |
|
|
|
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 13:26   |
Eclipse User |
|
|
|
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 #225749 is a reply to message #225670] |
Wed, 01 November 2006 18:08   |
Eclipse User |
|
|
|
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
|
|
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.04785 seconds