Home » Eclipse Projects » GEF » Contents Edit Part with 2 Layers
Contents Edit Part with 2 Layers [message #89991] |
Thu, 07 August 2003 10:49  |
Eclipse User |
|
|
|
Originally posted by: brian.fernandes.codito.com
I just wanted to clarify my technique on using the contents edit part with 2
layers.
Ref: Prevening certain figures from influencing scrolling.
For the Contents figure, I use a LayeredPane.
Then I add 2 dummy models to my Top Level model and their corresponding
figures (in their edit parts) are layers themselves.
Both layers would have different Layouts; one would use an XYLayout and
other a ToolBar Layout.
The problem I'm facing is, if I want to create an element, which layers
LayoutEditPolicy will get called ? I suppose the layer on top will receive
the create request.
Now, some figures I would want to create in the lower layer, and the others
in the upper layer.
So If I find that a figure must be created in the lower layer but I've
received the request in the upper layer, then what do I do ? How do I pass
this request to the lower layer ?
I hope this approach is correct, I'd appreciate any suggestions.
Thanks,
Brian.
|
|
|
Re: Contents Edit Part with 2 Layers [message #90020 is a reply to message #89991] |
Thu, 07 August 2003 11:34   |
Eclipse User |
|
|
|
Do you have a contents edit part with 2 child edit parts for the two layers?
You could probably catch the create request in the contents edit part, decide
which layer should get the new part, and then delegate the creation to the
appropriate child edit part.
Eric
Brian Fernandes wrote:
> I just wanted to clarify my technique on using the contents edit part with 2
> layers.
> Ref: Prevening certain figures from influencing scrolling.
>
> For the Contents figure, I use a LayeredPane.
> Then I add 2 dummy models to my Top Level model and their corresponding
> figures (in their edit parts) are layers themselves.
> Both layers would have different Layouts; one would use an XYLayout and
> other a ToolBar Layout.
>
> The problem I'm facing is, if I want to create an element, which layers
> LayoutEditPolicy will get called ? I suppose the layer on top will receive
> the create request.
> Now, some figures I would want to create in the lower layer, and the others
> in the upper layer.
>
> So If I find that a figure must be created in the lower layer but I've
> received the request in the upper layer, then what do I do ? How do I pass
> this request to the lower layer ?
>
> I hope this approach is correct, I'd appreciate any suggestions.
>
> Thanks,
> Brian.
>
>
>
>
>
>
|
|
| | |
Re: Contents Edit Part with 2 Layers [message #90225 is a reply to message #90095] |
Sat, 09 August 2003 10:08   |
Eclipse User |
|
|
|
Originally posted by: brian.fernandes.codito.com
"Randy Hudson" <none@us.ibm.com> wrote in message
news:bgv423$boj$1@eclipse.org...
> > The problem I'm facing is, if I want to create an element, which layers
> > LayoutEditPolicy will get called ? I suppose the layer on top will
> receive
> > the create request.
>
> Not necessarily, the requests can go through layers.
>
> If you look at LayoutEditPolicy:
> public EditPart getTargetEditPart(Request request) {
> if (REQ_ADD.equals(request.getType())
> || REQ_MOVE.equals(request.getType())
> || REQ_CREATE.equals(request.getType()))
> return getHost();
> return null;
> }
>
> Your XYLayoutEditPolicy will get targeted whenever the request is of type
> create. You can prevent this by overriding getTargetEditPart(request) in
> each of your layout editpolicies to only recognize create requests of the
> appropriate type.
I've done as you suggested and overriding getTargetEditPart seems to be
passing the requests appropriately.
I have layer P over layer Q, so I do all the filtering in layer P - I return
null for models inappropriate for layer P and then the request fall down to
layer Q.
However, both layers have to be OPAQUE to receive requests, & as a result,
objects are getting created in layer Q, but because of the Opacity of layer
P, they cannot be seen.
If I make P transparent, then P does not receive requests...
I followed a previous post on the topic, Ref: Again Layers.
So, for layer P (the layer on top), I used Figure instead of Layer and made
it transparent. (I had initially sublassed Figure and overridden
containsPoint and findFigureAt ~ but this reduced to the corresponding code
in Figure itself)
Now layer P behaves as required, I can target it for creation, selection,
moving & resizing.
I can target layer Q for creation but I can't select any of the EditParts in
Q even though they are visible. However, the layoutEditPolicies of the
EditParts in Q do get called when I try to create objects within Q. I can
also select the EditParts in Q using the Marquee too by dragging a rectangle
over them.
I have no idea what behavior I'm supposed to change, I tried pulling all
kinds of stunts with the transparency and the containsPoint and findFigureAt
functions but nothing seemed to get the desired functionality. I would like
it to behave as if all the figures were just in one Opaque layer. I also
tried overriding the paint method of the layer to do nothing and keep both
layers opaque, but that didn't work.
Another problem, you suggested earlier that I should use the ToolbarLayout.
What LayoutEditPolicy is suitable for using with this layout ?
FlowLayoutEditPolicy doesn't seem to work correctly.
Thanks,
Brian.
|
|
|
Re: Contents Edit Part with 2 Layers [message #90240 is a reply to message #90225] |
Sat, 09 August 2003 21:11   |
Eclipse User |
|
|
|
Originally posted by: none.us.ibm.com
"Brian Fernandes" <brian.fernandes@codito.com> wrote in message
news:bh2ujl$o2i$1@eclipse.org...
>
> "Randy Hudson" <none@us.ibm.com> wrote in message
> news:bgv423$boj$1@eclipse.org...
> > > The problem I'm facing is, if I want to create an element, which
layers
> > > LayoutEditPolicy will get called ? I suppose the layer on top will
> > receive
> > > the create request.
> >
> > Not necessarily, the requests can go through layers.
> >
> > If you look at LayoutEditPolicy:
> > public EditPart getTargetEditPart(Request request) {
> > if (REQ_ADD.equals(request.getType())
> > || REQ_MOVE.equals(request.getType())
> > || REQ_CREATE.equals(request.getType()))
> > return getHost();
> > return null;
> > }
> >
> > Your XYLayoutEditPolicy will get targeted whenever the request is of
type
> > create. You can prevent this by overriding getTargetEditPart(request)
in
> > each of your layout editpolicies to only recognize create requests of
the
> > appropriate type.
>
>
> I've done as you suggested and overriding getTargetEditPart seems to be
> passing the requests appropriately.
> I have layer P over layer Q, so I do all the filtering in layer P - I
return
> null for models inappropriate for layer P and then the request fall down
to
> layer Q.
> However, both layers have to be OPAQUE to receive requests, & as a
result,
> objects are getting created in layer Q, but because of the Opacity of
layer
> P, they cannot be seen.
> If I make P transparent, then P does not receive requests...
I think all that is necessary is that containsPoint(x, y) returns true.
Obvsiouly you don't want it opaque because then it will paint over the layer
underneath.
I haven't test this usage, but:
Figure#findDescendantAtExcluding(x, y, search);
was designed EXACTLY for this purpose. This method of searching should be
as flexible as generating the entire "picklist" for a point. So, the
contents figure would search through each of the two layers by calling
layer1.findFigureAt(x, y, search), layer2....
This method seems to only rely on containsPoint(x,y), and not isOpaque()
(whose value indirectly affects the default implementation of
containsPoint(x,y)
> I followed a previous post on the topic, Ref: Again Layers.
> So, for layer P (the layer on top), I used Figure instead of Layer and
made
> it transparent. (I had initially sublassed Figure and overridden
> containsPoint and findFigureAt ~ but this reduced to the corresponding
code
> in Figure itself)
> Now layer P behaves as required, I can target it for creation, selection,
> moving & resizing.
>
> I can target layer Q for creation but I can't select any of the EditParts
in
> Q even though they are visible. However, the layoutEditPolicies of the
> EditParts in Q do get called when I try to create objects within Q. I can
> also select the EditParts in Q using the Marquee too by dragging a
rectangle
> over them.
>
> I have no idea what behavior I'm supposed to change, I tried pulling all
> kinds of stunts with the transparency and the containsPoint and
findFigureAt
> functions but nothing seemed to get the desired functionality. I would
like
> it to behave as if all the figures were just in one Opaque layer. I also
> tried overriding the paint method of the layer to do nothing and keep both
> layers opaque, but that didn't work.
>
>
> Another problem, you suggested earlier that I should use the
ToolbarLayout.
> What LayoutEditPolicy is suitable for using with this layout ?
> FlowLayoutEditPolicy doesn't seem to work correctly.
>
> Thanks,
> Brian.
>
>
|
|
|
Re: Contents Edit Part with 2 Layers [message #90255 is a reply to message #90240] |
Mon, 11 August 2003 09:12   |
Eclipse User |
|
|
|
Originally posted by: brian.fernandes.codito.com
"Randy Hudson" <none@us.ibm.com> wrote in message
news:bh45vr$jmj$1@eclipse.org...
>
>
> "Brian Fernandes" <brian.fernandes@codito.com> wrote in message
> news:bh2ujl$o2i$1@eclipse.org...
> >
> > "Randy Hudson" <none@us.ibm.com> wrote in message
> > news:bgv423$boj$1@eclipse.org...
> > > > The problem I'm facing is, if I want to create an element, which
> layers
> > > > LayoutEditPolicy will get called ? I suppose the layer on top will
> > > receive
> > > > the create request.
> > >
> > > Not necessarily, the requests can go through layers.
> > >
> > > If you look at LayoutEditPolicy:
> > > public EditPart getTargetEditPart(Request request) {
> > > if (REQ_ADD.equals(request.getType())
> > > || REQ_MOVE.equals(request.getType())
> > > || REQ_CREATE.equals(request.getType()))
> > > return getHost();
> > > return null;
> > > }
> > >
> > > Your XYLayoutEditPolicy will get targeted whenever the request is of
> type
> > > create. You can prevent this by overriding getTargetEditPart(request)
> in
> > > each of your layout editpolicies to only recognize create requests of
> the
> > > appropriate type.
> >
> >
> > I've done as you suggested and overriding getTargetEditPart seems to be
> > passing the requests appropriately.
> > I have layer P over layer Q, so I do all the filtering in layer P - I
> return
> > null for models inappropriate for layer P and then the request fall down
> to
> > layer Q.
> > However, both layers have to be OPAQUE to receive requests, & as a
> result,
> > objects are getting created in layer Q, but because of the Opacity of
> layer
> > P, they cannot be seen.
> > If I make P transparent, then P does not receive requests...
>
> I think all that is necessary is that containsPoint(x, y) returns true.
> Obvsiouly you don't want it opaque because then it will paint over the
layer
> underneath.
>
> I haven't test this usage, but:
> Figure#findDescendantAtExcluding(x, y, search);
> was designed EXACTLY for this purpose. This method of searching should be
> as flexible as generating the entire "picklist" for a point. So, the
> contents figure would search through each of the two layers by calling
> layer1.findFigureAt(x, y, search), layer2....
>
> This method seems to only rely on containsPoint(x,y), and not isOpaque()
> (whose value indirectly affects the default implementation of
> containsPoint(x,y)
I'm afraid I wasn't able to follow this.
What I've done now is:
I made the layer on top (P) transparent as you've suggested. I overrode it's
Layer#findFigureAt(int x, int y, TreeSearch search) like so:
public IFigure findFigureAt(int x, int y, TreeSearch search) {
if (!isEnabled())
return null;
IFigure found = super.findFigureAt(x, y, search);
if(found != this) return found;
else return null;
}
This gives me almost all the functionality I need... ie. I can create new
objects in Layer Q, and EditParts in both P & Q are selectable.
However, since found would return null if the EditPart found was the layer
itself, I am unable to create new objects in layer P ...
Currently, my Contents EditPart is a LayeredPane to which I've simply added
2 Layers (P & Q). I have not set any layoutManager for the Contents
EditPart.
Could you be a bit more precise regarding how I am supposed to use
findDescendantAtExcluding ?
Do I have to change any behavior at all in the LayerePane (which is the
parent of the two layers)? Or do I just have to change the behavior of
Layer P.
I'm a bit wary of this because changes in findFigureAt may cause some
problems later on during other requests like creation or move besides
selection.
For instance, if I set layer P to be transparent but I ask findFigureAt to
simply "return super.findFigureAt(x, y, search)" (as if it were opaque) then
I am free to create objects in P and Q, but I cannot select object in Q.
BUT, if I am creating a new object (the type that goes in Q) at that time,
selection works (selectionHighlighting works) because the Create Requests
fall thru layer P.
I was reconsidering using a single layer with a hybrid Layoutmanager, but I
do want some objects (the objects in P) to always be drawn on top of the
others (the objects in Q). Besides, using different layout editpolicies
specialized to the type of layer are beneficial as well.
Perhaps I should catch all requests in the LayeredPane, filter them and then
delegate them to either of the two children layers, as Eric suggested ? But
I have no idea how this is done either or whether it is feasable at all.
If you could tell me what possibly needs to change in what EditPart, perhaps
I could better focus my efforts.
Thanks,
Brian.
|
|
|
Re: Contents Edit Part with 2 Layers [message #90270 is a reply to message #90255] |
Mon, 11 August 2003 09:57   |
Eclipse User |
|
|
|
Originally posted by: none.us.ibm.com
Please try adding this to your layer:
From Figure.java:
public IFigure findFigureAt(int x, int y, TreeSearch search) {
if (!containsPoint(x, y))
return null;
if (search.prune(this))
return null;
IFigure child = findDescendantAtExcluding(x, y, search);
if (child != null)
return child;
if (search.accept(this))
return this;
return null;
}
The key part is the line "if (search.accept(this))", which is what allows
that layer to be targeted, and also not be targeted.
AND, you must override Layer.containsPoint(int x, int y):
public boolean containsPoint(int x, int y) {
return true;
}
|
|
|
Re: Contents Edit Part with 2 Layers [message #90284 is a reply to message #90270] |
Mon, 11 August 2003 11:09   |
Eclipse User |
|
|
|
Originally posted by: brian.fernandes.codito.com
"Randy Hudson" <none@us.ibm.com> wrote in message
news:bh8779$kg6$1@eclipse.org...
> Please try adding this to your layer:
>
> From Figure.java:
>
> public IFigure findFigureAt(int x, int y, TreeSearch search) {
> if (!containsPoint(x, y))
> return null;
> if (search.prune(this))
> return null;
> IFigure child = findDescendantAtExcluding(x, y, search);
> if (child != null)
> return child;
> if (search.accept(this))
> return this;
> return null;
> }
>
I had already done this... my layer was a subclassed figure sorry for not
making that more clear. I hope you are talking about the Layer on top (layer
P). I have not touched either the layeredPane or the Lower layers
implementation.
> The key part is the line "if (search.accept(this))", which is what allows
> that layer to be targeted, and also not be targeted.
>
The search turns out to be an IdentitySearch, and returns true by default.
If "return this" executes (because search.accept(this)) returns true).
then I can can Create objects in P.good.
However, I can't select objects in Q (the lower layer). I can create objects
in Q however, and they even highlight according to my
SelectionHighlightEditPolicy, but ONLY during creation of objects in Q
because of the filtering done in getTargetEditPart of P's layoutEditPolicy.
If I am not creating an object , but using the selection tool,
getTargetEditPart in P does no such filtering and seleciton of objects in Q
does not work.
On the other hand, If I "return null" after search.accept(this) then I can't
create objects in P. (everthing else works.. I can create objects in Q,
select them and select objects that already exist in P (which were manually
created during the creation of P's model)
> AND, you must override Layer.containsPoint(int x, int y):
>
> public boolean containsPoint(int x, int y) {
> return true;
> }
I implemented this also. No change.
Any other ideas ? Perhaps make P opaque and override the paint method so
that it does not draw over. I tried this actually, even though you can see
and create objects in Q, you still cannot select them.
Thanks for the time,
Brian.
|
|
|
Re: Contents Edit Part with 2 Layers [message #90314 is a reply to message #90284] |
Mon, 11 August 2003 11:54   |
Eclipse User |
|
|
|
Originally posted by: none.us.ibm.com
You must be doing something else wrong. You should start debuggin in
TargetingTool.updateTargetEditPart();
I do not see the IndentitySearch being used, but instead a search
(GraphicalViewerImpl$ConditionalTreeSearch) which accepts figures based on
whether or not their corrseponding EditPart returns NULL for the target
editpart of the target request. This should work in both creation and
selection, as both are based on getTargetEditPart(Request), and I don't see
where either overrides updateTargetEditPart.
"Brian Fernandes" <brian.fernandes@codito.com> wrote in message
news:bh8ath$o88$1@eclipse.org...
>
> "Randy Hudson" <none@us.ibm.com> wrote in message
> news:bh8779$kg6$1@eclipse.org...
> > Please try adding this to your layer:
> >
> > From Figure.java:
> >
> > public IFigure findFigureAt(int x, int y, TreeSearch search) {
> > if (!containsPoint(x, y))
> > return null;
> > if (search.prune(this))
> > return null;
> > IFigure child = findDescendantAtExcluding(x, y, search);
> > if (child != null)
> > return child;
> > if (search.accept(this))
> > return this;
> > return null;
> > }
> >
>
> I had already done this... my layer was a subclassed figure sorry for not
> making that more clear. I hope you are talking about the Layer on top
(layer
> P). I have not touched either the layeredPane or the Lower layers
> implementation.
>
> > The key part is the line "if (search.accept(this))", which is what
allows
> > that layer to be targeted, and also not be targeted.
> >
>
>
> The search turns out to be an IdentitySearch, and returns true by default.
> If "return this" executes (because search.accept(this)) returns true).
> then I can can Create objects in P.good.
> However, I can't select objects in Q (the lower layer). I can create
objects
> in Q however, and they even highlight according to my
> SelectionHighlightEditPolicy, but ONLY during creation of objects in Q
> because of the filtering done in getTargetEditPart of P's
layoutEditPolicy.
> If I am not creating an object , but using the selection tool,
> getTargetEditPart in P does no such filtering and seleciton of objects in
Q
> does not work.
>
> On the other hand, If I "return null" after search.accept(this) then I
can't
> create objects in P. (everthing else works.. I can create objects in Q,
> select them and select objects that already exist in P (which were
manually
> created during the creation of P's model)
>
>
>
> > AND, you must override Layer.containsPoint(int x, int y):
> >
> > public boolean containsPoint(int x, int y) {
> > return true;
> > }
>
> I implemented this also. No change.
>
> Any other ideas ? Perhaps make P opaque and override the paint method so
> that it does not draw over. I tried this actually, even though you can see
> and create objects in Q, you still cannot select them.
>
>
> Thanks for the time,
> Brian.
>
>
>
>
|
|
|
Re: Contents Edit Part with 2 Layers [message #90329 is a reply to message #90314] |
Mon, 11 August 2003 13:04   |
Eclipse User |
|
|
|
Originally posted by: brian.fernandes.codito.com
"Randy Hudson" <none@us.ibm.com> wrote in message
news:bh8e2a$rtb$1@eclipse.org...
> You must be doing something else wrong. You should start debuggin in
> TargetingTool.updateTargetEditPart();
>
Well , I had placed a breakpoint on search.accept(this), it was always
identitySearch.
However, now I removed that and placed a breakpoint in the
ConditionTreeSearch. According to the stack , the call before that IS
search.accept(this).
so it is going thru the ConditionTreeSearch as well.
> I do not see the IndentitySearch being used, but instead a search
> (GraphicalViewerImpl$ConditionalTreeSearch) which accepts figures based on
> whether or not their corrseponding EditPart returns NULL for the target
> editpart of the target request. This should work in both creation and
> selection, as both are based on getTargetEditPart(Request), and I don't
see
> where either overrides updateTargetEditPart.
>
should I do a findFigureAt in getTargetEditpart (if the request is a
selection request) and see if anything from the the upper layer is being
selected. If not, I can return null and the selection request will pass down
to layer Q ?
Thanks again,
Brian.
|
|
|
Re: Contents Edit Part with 2 Layers [message #90344 is a reply to message #90329] |
Mon, 11 August 2003 13:00   |
Eclipse User |
|
|
|
Originally posted by: none.us.ibm.com
I think Eric's comment of forwarding may have confused you. You shouldn't
need to call findFigureAt anywhere. It is called indirectly by
TargetingTool.
all you have to do, is return getHost() from your LayoutEditPolicy at the
correct times, and null for objects which don't belong on that layer
"Brian Fernandes" <brian.fernandes@codito.com> wrote in message
news:bh8hme$vp6$1@eclipse.org...
>
> "Randy Hudson" <none@us.ibm.com> wrote in message
> news:bh8e2a$rtb$1@eclipse.org...
> > You must be doing something else wrong. You should start debuggin in
> > TargetingTool.updateTargetEditPart();
> >
>
> Well , I had placed a breakpoint on search.accept(this), it was always
> identitySearch.
> However, now I removed that and placed a breakpoint in the
> ConditionTreeSearch. According to the stack , the call before that IS
> search.accept(this).
> so it is going thru the ConditionTreeSearch as well.
>
>
>
> > I do not see the IndentitySearch being used, but instead a search
> > (GraphicalViewerImpl$ConditionalTreeSearch) which accepts figures based
on
> > whether or not their corrseponding EditPart returns NULL for the target
> > editpart of the target request. This should work in both creation and
> > selection, as both are based on getTargetEditPart(Request), and I don't
> see
> > where either overrides updateTargetEditPart.
> >
>
> should I do a findFigureAt in getTargetEditpart (if the request is a
> selection request) and see if anything from the the upper layer is being
> selected. If not, I can return null and the selection request will pass
down
> to layer Q ?
>
> Thanks again,
> Brian.
>
>
>
>
|
|
|
Re: Contents Edit Part with 2 Layers [message #90359 is a reply to message #90344] |
Mon, 11 August 2003 13:53   |
Eclipse User |
|
|
|
Originally posted by: brian.fernandes.codito.com
"Randy Hudson" <none@us.ibm.com> wrote in message
news:bh8hu1$ah$1@eclipse.org...
> I think Eric's comment of forwarding may have confused you. You shouldn't
> need to call findFigureAt anywhere. It is called indirectly by
> TargetingTool.
How I wish it had confused me... :(
I'm not calling findFigureAt from anywhere, I was only suggesting that
maybe I could use it in getTargetEditPart in P's LayoutEditPolicy to
perhaps decide where a select request could go.
I did follow your initial advice completely, and it worked fine. P's
getTargetEditPart checks the object being created, if the objects are
intended for it's layer, it returns getHost() else it returns null and as a
result, the create request falls down to the layer below it, layer Q.
The problem was that Q was being obscured because P is opaque.
There was a similar post on the group earlier. Dec 18 2002 - Again Layers.
That dude seems to have a similar problem, transparent edit parts need to te
targetable for requests; but he didn't explain his solution too clearly.
I'll lay down the facts.
Contents Edit Part: Opaque Layered Pane
Lower Layer(Q): Opaque Layer - FlowLayout
Upper Layer (P): Transparent extended Figure with overridden
containsPoint as you suggested, to return true. - XYLayout
LayoutEditPolicy with getTargetEditPart
modified as suggested to filter ADD, MOVE and CREATE requests. I'm unsure if
I can filter SELECT requests here too.
Problem: I cannot SELECT edit parts in layer Q though I am able to CREATE
edit parts there.
As an experiment, I tried returning null for ALL SELECT requests in
getTargetEditPart of P's LayoutEditPolicy. (by analogy to returning null for
misplaced CREATE requests leading to the CREATE request falling thru to
layer Q). However, this didn't work because of the following code in
AbstractEditPart#getTargetEditPart
if (RequestConstants.REQ_SELECTION == request.getType()) {
if (isSelectable())
return this;
}
I understand that this is taking a lot of your time. If you could tell me
exactly what functions I have to change in what classes and in what way ?
(I've already done all you suggested last time..my implementation is EXACTLY
what you suggested)
If I can't fix it, I'll shift focus for some time and come back at it
later... problem is it keeps nagging me; can't seem to proceed without it.
Thanks for your time again and again and again ...
Brian.
>
> all you have to do, is return getHost() from your LayoutEditPolicy at the
> correct times, and null for objects which don't belong on that layer
|
|
|
Re: Contents Edit Part with 2 Layers [message #90372 is a reply to message #90359] |
Mon, 11 August 2003 14:13   |
Eclipse User |
|
|
|
Originally posted by: none.us.ibm.com
EditPolicies combine to form the overall behavior of your editpart, so
returning null in one editpolicy doesn't guarantee that another editpolicy
doesn't return null.
Do editparts in layer Q have a SelectionEditPolicy?
Solution: put a breakpoint in SelectionTool.handleButtonDown(...), and find
out what is happening.
"Brian Fernandes" <brian.fernandes@codito.com> wrote in message
news:bh8khm$31m$1@eclipse.org...
>
> "Randy Hudson" <none@us.ibm.com> wrote in message
> news:bh8hu1$ah$1@eclipse.org...
> > I think Eric's comment of forwarding may have confused you. You
shouldn't
> > need to call findFigureAt anywhere. It is called indirectly by
> > TargetingTool.
>
> How I wish it had confused me... :(
>
> I'm not calling findFigureAt from anywhere, I was only suggesting that
> maybe I could use it in getTargetEditPart in P's LayoutEditPolicy to
> perhaps decide where a select request could go.
>
> I did follow your initial advice completely, and it worked fine. P's
> getTargetEditPart checks the object being created, if the objects are
> intended for it's layer, it returns getHost() else it returns null and as
a
> result, the create request falls down to the layer below it, layer Q.
>
> The problem was that Q was being obscured because P is opaque.
>
> There was a similar post on the group earlier. Dec 18 2002 - Again Layers.
> That dude seems to have a similar problem, transparent edit parts need to
te
> targetable for requests; but he didn't explain his solution too clearly.
>
> I'll lay down the facts.
>
> Contents Edit Part: Opaque Layered Pane
> Lower Layer(Q): Opaque Layer - FlowLayout
> Upper Layer (P): Transparent extended Figure with overridden
> containsPoint as you suggested, to return true. - XYLayout
> LayoutEditPolicy with
getTargetEditPart
> modified as suggested to filter ADD, MOVE and CREATE requests. I'm unsure
if
> I can filter SELECT requests here too.
>
> Problem: I cannot SELECT edit parts in layer Q though I am able to CREATE
> edit parts there.
>
> As an experiment, I tried returning null for ALL SELECT requests in
> getTargetEditPart of P's LayoutEditPolicy. (by analogy to returning null
for
> misplaced CREATE requests leading to the CREATE request falling thru to
> layer Q). However, this didn't work because of the following code in
> AbstractEditPart#getTargetEditPart
>
> if (RequestConstants.REQ_SELECTION == request.getType()) {
> if (isSelectable())
> return this;
> }
>
> I understand that this is taking a lot of your time. If you could tell me
> exactly what functions I have to change in what classes and in what way ?
> (I've already done all you suggested last time..my implementation is
EXACTLY
> what you suggested)
>
> If I can't fix it, I'll shift focus for some time and come back at it
> later... problem is it keeps nagging me; can't seem to proceed without it.
>
> Thanks for your time again and again and again ...
>
> Brian.
>
>
>
>
>
>
>
> >
> > all you have to do, is return getHost() from your LayoutEditPolicy at
the
> > correct times, and null for objects which don't belong on that layer
>
>
>
|
|
|
Re: Contents Edit Part with 2 Layers [message #90416 is a reply to message #90372] |
Tue, 12 August 2003 04:42   |
Eclipse User |
|
|
|
Originally posted by: brian.fernandes.codito.com
"Randy Hudson" <none@us.ibm.com> wrote in message
news:bh8m6u$4o6$1@eclipse.org...
> EditPolicies combine to form the overall behavior of your editpart, so
> returning null in one editpolicy doesn't guarantee that another editpolicy
> doesn't return null.
>
> Do editparts in layer Q have a SelectionEditPolicy?
>
Yes, all editparts have a SelecitonEditPolicy. installed on the
SELECTION_FEEDBACK_ROLE.
> Solution: put a breakpoint in SelectionTool.handleButtonDown(...), and
find
> out what is happening.
If I click an edit part in the upper layer P, then "EditPart editpart =
getTargetEditPart()" returns the correct Edit part, on which I clicked.
However, if I click on an editPart in Layer Q, then editpart returned is the
upper Layer's EditPart, (ie.P's editPart) and not the EditPart in Q.
I'm quite sure that this behavior is fine, according to the code we have
written before. All the select requests seem to be stopped at layer P
itself.
All I need is a layer that is transparent, but can still receive requests.
Is it possible for you to include this functionality in GEF somehow ? This
was requested earlier as well by another user, but I dunno....
Thanks,
Brian.
|
|
| |
Re: Contents Edit Part with 2 Layers [message #90492 is a reply to message #90447] |
Tue, 12 August 2003 11:02   |
Eclipse User |
|
|
|
Originally posted by: brian.fernandes.codito.com
"Randy Hudson" <none@us.ibm.com> wrote in message
news:bhas02$648$1@eclipse.org...
> > However, if I click on an editPart in Layer Q, then editpart returned is
> the
> > upper Layer's EditPart, (ie.P's editPart) and not the EditPart in Q.
>
> This is Wrong! Why would the user be able to select the layer? The layer
> should not be selectable.
I tried this out in the Logic example. If I click on some blank area of the
diagram,
"EditPart editpart = getTargetEditPart()" (in
SelectionTool.handleButtonDown(...) ), returns LogicDiagramEditPart which
is a FreeFormLayer.
The only difference is; in my app, I had another layer below this layer,
which was not getting the selection request, and editpart was P's EditPart.
>
> This function exists.
I thought it would be present in a extended Figure class. You specified that
I should make P transparent and change it's functions accordingly. Is that
all ?
Thanks,
Brian.
|
|
|
Re: Contents Edit Part with 2 Layers [message #90506 is a reply to message #90492] |
Tue, 12 August 2003 12:02   |
Eclipse User |
|
|
|
Originally posted by: none.us.ibm.com
"Brian Fernandes" <brian.fernandes@codito.com> wrote in message
news:bhauso$9en$1@eclipse.org...
>
> "Randy Hudson" <none@us.ibm.com> wrote in message
> news:bhas02$648$1@eclipse.org...
> > > However, if I click on an editPart in Layer Q, then editpart returned
is
> > the
> > > upper Layer's EditPart, (ie.P's editPart) and not the EditPart in Q.
> >
> > This is Wrong! Why would the user be able to select the layer? The
layer
> > should not be selectable.
>
> I tried this out in the Logic example. If I click on some blank area of
the
> diagram,
> "EditPart editpart = getTargetEditPart()" (in
> SelectionTool.handleButtonDown(...) ), returns LogicDiagramEditPart which
> is a FreeFormLayer.
If you had actually debugged this like I suggested, you would see that the
search condition is calling EditPart#isSelectable()
> The only difference is; in my app, I had another layer below this layer,
> which was not getting the selection request, and editpart was P's
EditPart.
>
> >
> > This function exists.
>
> I thought it would be present in a extended Figure class. You specified
that
> I should make P transparent and change it's functions accordingly. Is that
> all ?
>
> Thanks,
> Brian.
>
>
>
>
>
>
|
|
|
Re: Contents Edit Part with 2 Layers [message #91155 is a reply to message #90225] |
Tue, 26 August 2003 14:18   |
Eclipse User |
|
|
|
Originally posted by: brian.fernandes.codito.com
I seem to have finally solved this problem.
For the layer on top (P) use a non-opaque FIGURE, don't use a LAYER.
Override AbstractEditPart#isSelectable() in P's EditPart to return FALSE
instead of TRUE.
The editparts in Q were not selectable, because the layer P itself was
selectable. See AbstractEditPart#getTargetEditPart.
Of course, as Randy suggested , getTargetEditPart should be properly
overridden in P's EditPart to return either "null" or "getHost()"
according to the type of request and the objects being manipulated.
Thanks,
Brian.
Brian Fernandes wrote:
> "Randy Hudson" <none@us.ibm.com> wrote in message
> news:bgv423$boj$1@eclipse.org...
> > > The problem I'm facing is, if I want to create an element, which layers
> > > LayoutEditPolicy will get called ? I suppose the layer on top will
> > receive
> > > the create request.
> >
> > Not necessarily, the requests can go through layers.
> >
> > If you look at LayoutEditPolicy:
> > public EditPart getTargetEditPart(Request request) {
> > if (REQ_ADD.equals(request.getType())
> > || REQ_MOVE.equals(request.getType())
> > || REQ_CREATE.equals(request.getType()))
> > return getHost();
> > return null;
> > }
> >
> > Your XYLayoutEditPolicy will get targeted whenever the request is of type
> > create. You can prevent this by overriding getTargetEditPart(request) in
> > each of your layout editpolicies to only recognize create requests of the
> > appropriate type.
> I've done as you suggested and overriding getTargetEditPart seems to be
> passing the requests appropriately.
> I have layer P over layer Q, so I do all the filtering in layer P - I return
> null for models inappropriate for layer P and then the request fall down to
> layer Q.
> However, both layers have to be OPAQUE to receive requests, & as a result,
> objects are getting created in layer Q, but because of the Opacity of layer
> P, they cannot be seen.
> If I make P transparent, then P does not receive requests...
> I followed a previous post on the topic, Ref: Again Layers.
> So, for layer P (the layer on top), I used Figure instead of Layer and made
> it transparent. (I had initially sublassed Figure and overridden
> containsPoint and findFigureAt ~ but this reduced to the corresponding code
> in Figure itself)
> Now layer P behaves as required, I can target it for creation, selection,
> moving & resizing.
> I can target layer Q for creation but I can't select any of the EditParts in
> Q even though they are visible. However, the layoutEditPolicies of the
> EditParts in Q do get called when I try to create objects within Q. I can
> also select the EditParts in Q using the Marquee too by dragging a rectangle
> over them.
> I have no idea what behavior I'm supposed to change, I tried pulling all
> kinds of stunts with the transparency and the containsPoint and findFigureAt
> functions but nothing seemed to get the desired functionality. I would like
> it to behave as if all the figures were just in one Opaque layer. I also
> tried overriding the paint method of the layer to do nothing and keep both
> layers opaque, but that didn't work.
> Another problem, you suggested earlier that I should use the ToolbarLayout.
> What LayoutEditPolicy is suitable for using with this layout ?
> FlowLayoutEditPolicy doesn't seem to work correctly.
> Thanks,
> Brian.
|
|
| | | | | | | |
Re: Contents Edit Part with 2 Layers [message #106126 is a reply to message #106074] |
Thu, 20 November 2003 16:14   |
Eclipse User |
|
|
|
Originally posted by: none.us.ibm.com
It's used in the palette, for rollover display of truncated labels.
Read my previous response, and replace all of my question marks with periods
:-).
"Brian Fernandes" <brian.fernandes@codito.com> wrote in message
news:bpiotr$fkh$1@eclipse.org...
>
> "Randy Hudson" <none@us.ibm.com> wrote in message
> news:bpilqi$b33$1@eclipse.org...
> > Wouldn't you be doing the opposite? The requests location is absolute,
so
> > you want the location relative to the parent (feedback layer?) of the
> popup
> > figure.
>
> No, what I have noticed is that the requests location is not absolute but
> relative ? I hope I've used the terminology correctly.
>
> That means if my viewport or window is about 800 pixels across .. (if it
> takes 800 pixels of screen space) and my mouse is in the middle of the
> viewport, the x location is 400. Now if I scroll the view and place my
mouse
> at exactly the same position on my monitor then I still get 400. I guess
> these are relative coordinates right ?
>
> I would like the label to follow the mouse, so what happens now is that if
I
> scroll right, the label moves left form the mouse location. Thats because
> I'm setting its location to 400 where it should have been 600 perhaps on
the
> canvas. I use addFeedback to add the figure to the feedback layer - which
I
> assume would require absolute coordinates.
>
> Basically I need to know how much the window has been scrolled (in x and
y)
> and simply offset the requests location by that amount. I'm sure that is
> what I need, just how to get it I don't know.
>
> >
> > Also, we have PopupHelper class which lets you make a "real" popup
(using
> > another Shell) which can extend past the viewer's bounds.
>
>
> I don't really need something like this; what I have now seems good
> enough... but I will look into it. I assume I will face similar problems
> though... any tips on how to use it... I don't think it's used in Logic
....
>
> Thanks again,
> Brian.
>
>
|
|
| |
Re: Contents Edit Part with 2 Layers [message #106219 is a reply to message #105818] |
Fri, 21 November 2003 10:58  |
Eclipse User |
|
|
|
Originally posted by: brian.fernandes.codito.com
One more problem *sigh*
Below are the important parts of the EditPolicy.
What I do is create a new label if required... and update it's location
constantly.
When eraseTargetFeedback is called, I simply remove the label from the
feedback layer.
This works fine in most cases, but when I'm dragging edit parts around,
labels get left behind and are not erased.
To counter this, I overrode the dispose method as shown... this is even
better the labels are never left behind.
But occasionally I get an IllegalArgumentException saying - "Figure is not a
child of this parent." Then the whole editor just screws up.
I tried looking at PopupHelper but couldn't really figure out how this is
used. Though right now I'd rather fix the current implementation.
Any way in which I can fix this implementation ?
Thanks again,
Brian.
public void showTargetFeedback(Request request){
try {
showName(((LocationRequest)request).getLocation());
}
catch(ClassCastException e) {}
}
protected void showName(Point location) {
Point l2 = location.getCopy();
try {
if(feedbackLabel == null) {
feedbackLabel = new Label(((SElement)(getHost().getModel())).name);
addFeedback(feedbackLabel);
feedbackLabel.setFont(font);
feedbackLabel.setForegroundColor(ColorConstants.blue);
feedbackLabel.setBounds(feedbackLabel.getTextBounds());
}
feedbackLabel.translateToRelative(l2);
feedbackLabel.setLocation(new Point(l2.x + 10, l2.y));
}
catch(ClassCastException e) {}
}
public void eraseTargetFeedback(Request request) {
if(feedbackLabel != null) {
removeFeedback(feedbackLabel);
feedbackLabel = null;
}
}
public void deactivate() {
super.deactivate();
if(feedbackLabel != null) {
removeFeedback(feedbackLabel);
}
}
|
|
|
Goto Forum:
Current Time: Mon May 12 10:25:17 EDT 2025
Powered by FUDForum. Page generated in 0.10661 seconds
|