Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » GEF » Selectable but not movable
Selectable but not movable [message #135147] Mon, 31 May 2004 21:01 Go to next message
Eclipse UserFriend
Originally posted by: gaanni.sasdf.sss

I need to be able to set the property of an editpart/model, but dont want
it to be movable. How do i achieve this?
Re: Selectable but not movable [message #135158 is a reply to message #135147] Mon, 31 May 2004 22:36 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: rlemaigr.ulb.ac.be

I'm not sure at all about this but I will answer you anyway, so you will=
=

have something to try before getting the good answer from somebody else.=


If you install a NonResizableEditPolicy on the primary drag role of the =
=

host and if the getCommand method of the NonResizableEditPolicy returns =
=

null for the move requests, the host EditPart will not be movable and it=
=

will still be selectable. But the ghost rectangle for displaying feedbac=
k =

will be shown (I'm not sure about this) and I suppose that it is what yo=
u =

want to avoid. So we have to find another solution...

So first you want your EditPart to be selectable.

There are two requirements fot this:
- the method isSelectable() of your EditPart must return true,
- the method getTargetEditPart(Request) of your EditPart must return =

"this" for the SelectionRequest of the type REQ_SELECTION (I think).

Unless you overrides the super implementation of the isSelectable method=
, =

the first requirement is already satisfied.

The second requirement is not satisfied by default. By default the =

getTargetEditPart(Request) method of EditPart delegate the call to the =

getTargetEditPart of the installed editpolicies. So you have to install =
on =

your EditPart an EditPolicy with a getTargetEditPart() method which =

returns getHost() for the selection requests. All the subclasses of =

SelectionEditPolicy do this. So the NonResizableEditPolicy and the =

ResizableEditPolicy do this also. But they show source feedback when you=
=

try to move your EditPart (if they don't, all my explanations are totall=
y =

useless so I hope they do :D ) and that's our problem.

So what I would do if I would be you would be writting a subclass =

SelectionEditPolicy and installing it on the primary drag role of your =

EditPart. Like that, it will become selectable. But there is no selectio=
n =

feedback shown by default by the SelectionEditPolicy class.

SelectionEditPolicy is an abstract class. When this editpolicy is =

installed on an EditPart, it listens to the selection state of its host,=
=

and when this selection state changes, it calls one of the two abstract =
=

methods showSelectionFeedback/hideSelectionFeedbak for show/hide selecti=
on =

feedback on the host Figure. So you would have to implement these two =

methods to show customized feedback. Maybe a black square or a "negative=
=

image" of the EditPart by swapping the background and foreground color o=
f =

its Figure, I don't know...

SelectionEditPolicy is a GraphicalEditPolicy so it has methods to help y=
ou =

to show feedback, and specially the methods add/removeFeedback(IFigure) =
=

which add/remove feedback from the feedback layer. For examples about ho=
w =

to show feedback, you could take a look in the code of =

NonResizableEditPolicy.

There is probably a much simpler answer to your question but I don't kno=
w =

it...

I hope this has helped you,

r=E9gis


On Mon, 31 May 2004 21:01:17 +0000 (UTC), Gani <gaanni@sasdf.sss> wrote:=


> I need to be able to set the property of an editpart/model, but dont w=
ant
> it to be movable. How do i achieve this?
>



-- =

Using Opera's revolutionary e-mail client: http://www.opera.com/m2/
Re: Selectable but not movable [message #135171 is a reply to message #135158] Tue, 01 June 2004 00:31 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: none.us.ibm.com

IMO, you don't want handles at all if you can't move the editpart. I would
write my own SelectionEditPolicy which indicates selection by changing the
figures colors to LIST_SELECTED_FOREGROUND and LIST_SELECTED_BACKGROUND.
Similar to the flow example.

The DragEditPartsTracker should be filtering out editparts which don't
understand dragging. If it isn't doing this, you can create you own tracker
and override getOperationSet() to exclude the unmovable parts.

<rlemaigr@ulb.ac.be> wrote in message
news:opr8vyfh06xn9g2u@xn--pcrgis-dva.mshome.net...
I'm not sure at all about this but I will answer you anyway, so you will
have something to try before getting the good answer from somebody else.

If you install a NonResizableEditPolicy on the primary drag role of the
host and if the getCommand method of the NonResizableEditPolicy returns
null for the move requests, the host EditPart will not be movable and it
will still be selectable. But the ghost rectangle for displaying feedback
will be shown (I'm not sure about this) and I suppose that it is what you
want to avoid. So we have to find another solution...

So first you want your EditPart to be selectable.

There are two requirements fot this:
- the method isSelectable() of your EditPart must return true,
- the method getTargetEditPart(Request) of your EditPart must return
"this" for the SelectionRequest of the type REQ_SELECTION (I think).

Unless you overrides the super implementation of the isSelectable method,
the first requirement is already satisfied.

The second requirement is not satisfied by default. By default the
getTargetEditPart(Request) method of EditPart delegate the call to the
getTargetEditPart of the installed editpolicies. So you have to install on
your EditPart an EditPolicy with a getTargetEditPart() method which
returns getHost() for the selection requests. All the subclasses of
SelectionEditPolicy do this. So the NonResizableEditPolicy and the
ResizableEditPolicy do this also. But they show source feedback when you
try to move your EditPart (if they don't, all my explanations are totally
useless so I hope they do :D ) and that's our problem.

So what I would do if I would be you would be writting a subclass
SelectionEditPolicy and installing it on the primary drag role of your
EditPart. Like that, it will become selectable. But there is no selection
feedback shown by default by the SelectionEditPolicy class.

SelectionEditPolicy is an abstract class. When this editpolicy is
installed on an EditPart, it listens to the selection state of its host,
and when this selection state changes, it calls one of the two abstract
methods showSelectionFeedback/hideSelectionFeedbak for show/hide selection
feedback on the host Figure. So you would have to implement these two
methods to show customized feedback. Maybe a black square or a "negative
image" of the EditPart by swapping the background and foreground color of
its Figure, I don't know...

SelectionEditPolicy is a GraphicalEditPolicy so it has methods to help you
to show feedback, and specially the methods add/removeFeedback(IFigure)
which add/remove feedback from the feedback layer. For examples about how
to show feedback, you could take a look in the code of
NonResizableEditPolicy.

There is probably a much simpler answer to your question but I don't know
it...

I hope this has helped you,

r
Re: Selectable but not movable [message #135345 is a reply to message #135171] Tue, 01 June 2004 13:52 Go to previous message
Eclipse UserFriend
Originally posted by: gani.gaaanni.ccc

I will try these solutions.

Thanks
Gani

Randy Hudson wrote:

> IMO, you don't want handles at all if you can't move the editpart. I would
> write my own SelectionEditPolicy which indicates selection by changing the
> figures colors to LIST_SELECTED_FOREGROUND and LIST_SELECTED_BACKGROUND.
> Similar to the flow example.

> The DragEditPartsTracker should be filtering out editparts which don't
> understand dragging. If it isn't doing this, you can create you own tracker
> and override getOperationSet() to exclude the unmovable parts.

> <rlemaigr@ulb.ac.be> wrote in message
> news:opr8vyfh06xn9g2u@xn--pcrgis-dva.mshome.net...
> I'm not sure at all about this but I will answer you anyway, so you will
> have something to try before getting the good answer from somebody else.

> If you install a NonResizableEditPolicy on the primary drag role of the
> host and if the getCommand method of the NonResizableEditPolicy returns
> null for the move requests, the host EditPart will not be movable and it
> will still be selectable. But the ghost rectangle for displaying feedback
> will be shown (I'm not sure about this) and I suppose that it is what you
> want to avoid. So we have to find another solution...

> So first you want your EditPart to be selectable.

> There are two requirements fot this:
> - the method isSelectable() of your EditPart must return true,
> - the method getTargetEditPart(Request) of your EditPart must return
> "this" for the SelectionRequest of the type REQ_SELECTION (I think).

> Unless you overrides the super implementation of the isSelectable method,
> the first requirement is already satisfied.

> The second requirement is not satisfied by default. By default the
> getTargetEditPart(Request) method of EditPart delegate the call to the
> getTargetEditPart of the installed editpolicies. So you have to install on
> your EditPart an EditPolicy with a getTargetEditPart() method which
> returns getHost() for the selection requests. All the subclasses of
> SelectionEditPolicy do this. So the NonResizableEditPolicy and the
> ResizableEditPolicy do this also. But they show source feedback when you
> try to move your EditPart (if they don't, all my explanations are totally
> useless so I hope they do :D ) and that's our problem.

> So what I would do if I would be you would be writting a subclass
> SelectionEditPolicy and installing it on the primary drag role of your
> EditPart. Like that, it will become selectable. But there is no selection
> feedback shown by default by the SelectionEditPolicy class.

> SelectionEditPolicy is an abstract class. When this editpolicy is
> installed on an EditPart, it listens to the selection state of its host,
> and when this selection state changes, it calls one of the two abstract
> methods showSelectionFeedback/hideSelectionFeedbak for show/hide selection
> feedback on the host Figure. So you would have to implement these two
> methods to show customized feedback. Maybe a black square or a "negative
> image" of the EditPart by swapping the background and foreground color of
> its Figure, I don't know...

> SelectionEditPolicy is a GraphicalEditPolicy so it has methods to help you
> to show feedback, and specially the methods add/removeFeedback(IFigure)
> which add/remove feedback from the feedback layer. For examples about how
> to show feedback, you could take a look in the code of
> NonResizableEditPolicy.

> There is probably a much simpler answer to your question but I don't know
> it...

> I hope this has helped you,

> régis


> On Mon, 31 May 2004 21:01:17 +0000 (UTC), Gani <gaanni@sasdf.sss> wrote:

> > I need to be able to set the property of an editpart/model, but dont want
> > it to be movable. How do i achieve this?
> >
Previous Topic:multiple selections question
Next Topic:Relative bendpoint positioning
Goto Forum:
  


Current Time: Wed Apr 24 23:56:31 GMT 2024

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

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

Back to the top