Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » GEF » EditPart selection feedback
EditPart selection feedback [message #233127] Tue, 17 April 2007 16:22 Go to next message
Eclipse UserFriend
Originally posted by: michele.l.evinco.it

I want to change the backgroud color of the an editpart when i click on
it so i've written this code in createEditPolicies of my editpart:

installEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE,
new SelectionEditPolicy(){
protected void hideSelection() {
((AntennaFigure)getFigure()).setOpaque(true);
((AntennaFigure)getFigure()).setBackgroundColor(org.eclipse. draw2d.ColorConstants.black);

}

protected void showSelection() {
((AntennaFigure)getFigure()).setOpaque(false);
((AntennaFigure)getFigure()).setBackgroundColor(org.eclipse. draw2d.ColorConstants.white);
}

});

When i click on the figure that rappresent my editpart notthing appends
and the code of showSelection is never executed.


My way is correct?
What 's the best way to do this?
When an editPart is Selected? on mouse click?

Thank's
Michele
Re: EditPart selection feedback [message #233135 is a reply to message #233127] Wed, 18 April 2007 00:24 Go to previous messageGo to next message
Sun Seng David TAN is currently offline Sun Seng David TANFriend
Messages: 12
Registered: July 2009
Junior Member
hi

My way to do it would be to create a resizableEditPolicy
and override the method
protected IFigure createDragSourceFeedbackFigure()
where you create the feedback figure (that would be the same figure with
a different background)


protected IFigure createDragSourceFeedbackFigure()

michele wrote:
> I want to change the backgroud color of the an editpart when i click on
> it so i've written this code in createEditPolicies of my editpart:
>
> installEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE,
> new SelectionEditPolicy(){
> protected void hideSelection() {
> ((AntennaFigure)getFigure()).setOpaque(true);
> ((AntennaFigure)getFigure()).setBackgroundColor(org.eclipse. draw2d.ColorConstants.black);
>
>
> }
>
> protected void showSelection() {
> ((AntennaFigure)getFigure()).setOpaque(false);
> ((AntennaFigure)getFigure()).setBackgroundColor(org.eclipse. draw2d.ColorConstants.white);
>
> }
>
> });
>
> When i click on the figure that rappresent my editpart notthing appends
> and the code of showSelection is never executed.
>
>
> My way is correct?
> What 's the best way to do this?
> When an editPart is Selected? on mouse click?
>
> Thank's
> Michele
Re: EditPart selection feedback [message #233151 is a reply to message #233135] Wed, 18 April 2007 08:37 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: michele.l.evinco.it

Thank you for your reply David,
i've try with your way but when i click or double click on the figure
the code of createDragSourceFeedbackFigure() is never executed.
I've register it as EditPolicy.SELECTION_FEEDBACK_ROLE.
How do you register it?


Sun Seng David TAN wrote:
> hi
>
> My way to do it would be to create a resizableEditPolicy
> and override the method
> protected IFigure createDragSourceFeedbackFigure()
> where you create the feedback figure (that would be the same figure with
> a different background)
>
>
> protected IFigure createDragSourceFeedbackFigure()
>
> michele wrote:
>
>> I want to change the backgroud color of the an editpart when i click
>> on it so i've written this code in createEditPolicies of my editpart:
>>
>> installEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE,
>> new SelectionEditPolicy(){
>> protected void hideSelection() {
>> ((AntennaFigure)getFigure()).setOpaque(true);
>> ((AntennaFigure)getFigure()).setBackgroundColor(org.eclipse. draw2d.ColorConstants.black);
>>
>> }
>>
>> protected void showSelection() {
>> ((AntennaFigure)getFigure()).setOpaque(false);
>> ((AntennaFigure)getFigure()).setBackgroundColor(org.eclipse. draw2d.ColorConstants.white);
>>
>> }
>> });
>>
>> When i click on the figure that rappresent my editpart notthing
>> appends and the code of showSelection is never executed.
>>
>>
>> My way is correct?
>> What 's the best way to do this?
>> When an editPart is Selected? on mouse click?
>>
>> Thank's
>> Michele
Re: EditPart selection feedback [message #233191 is a reply to message #233151] Thu, 19 April 2007 01:28 Go to previous messageGo to next message
Sun Seng David TAN is currently offline Sun Seng David TANFriend
Messages: 12
Registered: July 2009
Junior Member
mh ... :S
that's the way im registering it ....
but that works when you try to drag the figure, im not sure if it is
really what you want to do

michele a écrit :
> Thank you for your reply David,
> i've try with your way but when i click or double click on the figure
> the code of createDragSourceFeedbackFigure() is never executed.
> I've register it as EditPolicy.SELECTION_FEEDBACK_ROLE.
> How do you register it?
>
>
> Sun Seng David TAN wrote:
>> hi
>>
>> My way to do it would be to create a resizableEditPolicy
>> and override the method
>> protected IFigure createDragSourceFeedbackFigure()
>> where you create the feedback figure (that would be the same figure
>> with a different background)
>>
>>
>> protected IFigure createDragSourceFeedbackFigure()
>>
>> michele wrote:
>>
>>> I want to change the backgroud color of the an editpart when i click
>>> on it so i've written this code in createEditPolicies of my editpart:
>>>
>>> installEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE,
>>> new SelectionEditPolicy(){
>>> protected void hideSelection() {
>>> ((AntennaFigure)getFigure()).setOpaque(true);
>>> ((AntennaFigure)getFigure()).setBackgroundColor(org.eclipse. draw2d.ColorConstants.black);
>>>
>>> }
>>>
>>> protected void showSelection() {
>>> ((AntennaFigure)getFigure()).setOpaque(false);
>>> ((AntennaFigure)getFigure()).setBackgroundColor(org.eclipse. draw2d.ColorConstants.white);
>>>
>>> }
>>> });
>>>
>>> When i click on the figure that rappresent my editpart notthing
>>> appends and the code of showSelection is never executed.
>>>
>>>
>>> My way is correct?
>>> What 's the best way to do this?
>>> When an editPart is Selected? on mouse click?
>>>
>>> Thank's
>>> Michele
Re: EditPart selection feedback [message #233199 is a reply to message #233151] Thu, 19 April 2007 02:07 Go to previous messageGo to next message
Sun Seng David TAN is currently offline Sun Seng David TANFriend
Messages: 12
Registered: July 2009
Junior Member
So ....
i'm registering it from the parent layoutEditPolicy from the method
createChildEditPolicy.. if you have a look to the Logic diagram example
you will find in the class
org.eclipse.gef.examples.logicdesigner.edit.LogicXYLayoutEdi tPolicy the
way to do it :


protected EditPolicy createChildEditPolicy(EditPart child) {
if (child instanceof LEDEditPart
|| child instanceof OutputEditPart) {
ResizableEditPolicy policy = new LogicResizableEditPolicy();
policy.setResizeDirections(0);
return policy;
} else if (child instanceof LogicLabelEditPart) {
ResizableEditPolicy policy = new LogicResizableEditPolicy();
policy.setResizeDirections(PositionConstants.EAST |
PositionConstants.WEST);
return policy;
}

return new LogicResizableEditPolicy();
}

michele a écrit :
> Thank you for your reply David,
> i've try with your way but when i click or double click on the figure
> the code of createDragSourceFeedbackFigure() is never executed.
> I've register it as EditPolicy.SELECTION_FEEDBACK_ROLE.
> How do you register it?
>
>
> Sun Seng David TAN wrote:
>> hi
>>
>> My way to do it would be to create a resizableEditPolicy
>> and override the method
>> protected IFigure createDragSourceFeedbackFigure()
>> where you create the feedback figure (that would be the same figure
>> with a different background)
>>
>>
>> protected IFigure createDragSourceFeedbackFigure()
>>
>> michele wrote:
>>
>>> I want to change the backgroud color of the an editpart when i click
>>> on it so i've written this code in createEditPolicies of my editpart:
>>>
>>> installEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE,
>>> new SelectionEditPolicy(){
>>> protected void hideSelection() {
>>> ((AntennaFigure)getFigure()).setOpaque(true);
>>> ((AntennaFigure)getFigure()).setBackgroundColor(org.eclipse. draw2d.ColorConstants.black);
>>>
>>> }
>>>
>>> protected void showSelection() {
>>> ((AntennaFigure)getFigure()).setOpaque(false);
>>> ((AntennaFigure)getFigure()).setBackgroundColor(org.eclipse. draw2d.ColorConstants.white);
>>>
>>> }
>>> });
>>>
>>> When i click on the figure that rappresent my editpart notthing
>>> appends and the code of showSelection is never executed.
>>>
>>>
>>> My way is correct?
>>> What 's the best way to do this?
>>> When an editPart is Selected? on mouse click?
>>>
>>> Thank's
>>> Michele
Re: EditPart selection feedback [message #233229 is a reply to message #233199] Thu, 19 April 2007 08:15 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: michele.l.evinco.it

thank's David for your replay,
I've find this solution :
i've register my SelectionEditPolicy as EditPolicy.SELECTION_FEEDBACK_ROLE.
then in the edit part i've add a EditPartListener and implement his
selectedStateChanged method where i change the background of figure.
I don't know if this is the right way to do that but it work.

Bye
Michele

Sun Seng David TAN wrote:
> So ....
> i'm registering it from the parent layoutEditPolicy from the method
> createChildEditPolicy.. if you have a look to the Logic diagram example
> you will find in the class
> org.eclipse.gef.examples.logicdesigner.edit.LogicXYLayoutEdi tPolicy the
> way to do it :
>
>
> protected EditPolicy createChildEditPolicy(EditPart child) {
> if (child instanceof LEDEditPart
> || child instanceof OutputEditPart) {
> ResizableEditPolicy policy = new LogicResizableEditPolicy();
> policy.setResizeDirections(0);
> return policy;
> } else if (child instanceof LogicLabelEditPart) {
> ResizableEditPolicy policy = new LogicResizableEditPolicy();
> policy.setResizeDirections(PositionConstants.EAST |
> PositionConstants.WEST);
> return policy;
> }
>
> return new LogicResizableEditPolicy();
> }
>
> michele a écrit :
>
>> Thank you for your reply David,
>> i've try with your way but when i click or double click on the figure
>> the code of createDragSourceFeedbackFigure() is never executed.
>> I've register it as EditPolicy.SELECTION_FEEDBACK_ROLE.
>> How do you register it?
>>
>>
>> Sun Seng David TAN wrote:
>>
>>> hi
>>>
>>> My way to do it would be to create a resizableEditPolicy
>>> and override the method
>>> protected IFigure createDragSourceFeedbackFigure()
>>> where you create the feedback figure (that would be the same figure
>>> with a different background)
>>>
>>>
>>> protected IFigure createDragSourceFeedbackFigure()
>>>
>>> michele wrote:
>>>
>>>> I want to change the backgroud color of the an editpart when i click
>>>> on it so i've written this code in createEditPolicies of my editpart:
>>>>
>>>> installEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE,
>>>> new SelectionEditPolicy(){
>>>> protected void hideSelection() {
>>>> ((AntennaFigure)getFigure()).setOpaque(true);
>>>> ((AntennaFigure)getFigure()).setBackgroundColor(org.eclipse. draw2d.ColorConstants.black);
>>>>
>>>> }
>>>>
>>>> protected void showSelection() {
>>>> ((AntennaFigure)getFigure()).setOpaque(false);
>>>> ((AntennaFigure)getFigure()).setBackgroundColor(org.eclipse. draw2d.ColorConstants.white);
>>>>
>>>> }
>>>> });
>>>>
>>>> When i click on the figure that rappresent my editpart notthing
>>>> appends and the code of showSelection is never executed.
>>>>
>>>>
>>>> My way is correct?
>>>> What 's the best way to do this?
>>>> When an editPart is Selected? on mouse click?
>>>>
>>>> Thank's
>>>> Michele
Re: EditPart selection feedback [message #233237 is a reply to message #233229] Thu, 19 April 2007 08:27 Go to previous message
Eclipse UserFriend
Originally posted by: michele.l.evinco.it

correction:
It works without register the policy.
In the deactivate method of editpart i must remove the listener
otherwise an errror will be generated.

michele wrote:
> thank's David for your replay,
> I've find this solution :
> i've register my SelectionEditPolicy as EditPolicy.SELECTION_FEEDBACK_ROLE.
> then in the edit part i've add a EditPartListener and implement his
> selectedStateChanged method where i change the background of figure.
> I don't know if this is the right way to do that but it work.
>
> Bye
> Michele
>
> Sun Seng David TAN wrote:
>
>> So ....
>> i'm registering it from the parent layoutEditPolicy from the method
>> createChildEditPolicy.. if you have a look to the Logic diagram
>> example you will find in the class
>> org.eclipse.gef.examples.logicdesigner.edit.LogicXYLayoutEdi tPolicy
>> the way to do it :
>>
>>
>> protected EditPolicy createChildEditPolicy(EditPart child) {
>> if (child instanceof LEDEditPart
>> || child instanceof OutputEditPart) {
>> ResizableEditPolicy policy = new LogicResizableEditPolicy();
>> policy.setResizeDirections(0);
>> return policy;
>> } else if (child instanceof LogicLabelEditPart) {
>> ResizableEditPolicy policy = new LogicResizableEditPolicy();
>> policy.setResizeDirections(PositionConstants.EAST |
>> PositionConstants.WEST);
>> return policy;
>> }
>> return new LogicResizableEditPolicy();
>> }
>>
>> michele a écrit :
>>
>>> Thank you for your reply David,
>>> i've try with your way but when i click or double click on the figure
>>> the code of createDragSourceFeedbackFigure() is never executed.
>>> I've register it as EditPolicy.SELECTION_FEEDBACK_ROLE.
>>> How do you register it?
>>>
>>>
>>> Sun Seng David TAN wrote:
>>>
>>>> hi
>>>>
>>>> My way to do it would be to create a resizableEditPolicy
>>>> and override the method
>>>> protected IFigure createDragSourceFeedbackFigure()
>>>> where you create the feedback figure (that would be the same figure
>>>> with a different background)
>>>>
>>>>
>>>> protected IFigure createDragSourceFeedbackFigure()
>>>>
>>>> michele wrote:
>>>>
>>>>> I want to change the backgroud color of the an editpart when i
>>>>> click on it so i've written this code in createEditPolicies of my
>>>>> editpart:
>>>>>
>>>>> installEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE,
>>>>> new SelectionEditPolicy(){
>>>>> protected void hideSelection() {
>>>>> ((AntennaFigure)getFigure()).setOpaque(true);
>>>>> ((AntennaFigure)getFigure()).setBackgroundColor(org.eclipse. draw2d.ColorConstants.black);
>>>>>
>>>>> }
>>>>>
>>>>> protected void showSelection() {
>>>>> ((AntennaFigure)getFigure()).setOpaque(false);
>>>>> ((AntennaFigure)getFigure()).setBackgroundColor(org.eclipse. draw2d.ColorConstants.white);
>>>>>
>>>>> }
>>>>> });
>>>>>
>>>>> When i click on the figure that rappresent my editpart notthing
>>>>> appends and the code of showSelection is never executed.
>>>>>
>>>>>
>>>>> My way is correct?
>>>>> What 's the best way to do this?
>>>>> When an editPart is Selected? on mouse click?
>>>>>
>>>>> Thank's
>>>>> Michele
Previous Topic:Add decoration to EditPart?
Next Topic:change the color of the editor background
Goto Forum:
  


Current Time: Fri Mar 29 15:55:00 GMT 2024

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

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

Back to the top