Home » Eclipse Projects » GEF » Make Label to have several editable parts?
Make Label to have several editable parts? [message #56035] |
Sat, 18 January 2003 19:58 |
Hal Messages: 67 Registered: July 2009 |
Member |
|
|
Thanks. I try this, but the getLocation() always return me the *SAME*
co-ordinate regardless where I click on the label.
Here is what I did:
- create a new LocationEditManager and in its createDirectEditRequest(),
copy the location from the incoming directEditRequest to this new Direct
edit request that it is going to create.
protected DirectEditRequest createDirectEditRequest(){
DirectEditRequest req = new DirectEditRequest();
if (request != null){
req.setLocation(incomingDirectEditRequest.getLocation());
}
req.setCellEditor(getCellEditor());
return req;
}
- create a new DirectEditPolicy, I print out the location of the request:
But the location is ALWAYS the same, regardless where I click the label:
protected void showCurrentEditValue(DirectEditRequest request) {
System.out.println ("showCurrentEditValue x:" + request.getLocation().x + "
y:" + request.getLocation().y);
LogicSubpart host =
(LogicSubpart)((AbstractGraphicalEditPart)getHost()).getMode l();
//...
}
- in my editPart, I install this new direct edit policy and create my new
directEditManager when necessary.
Could you please if I miss anything? What I want to do is I have a label
looks like this "XX / MM / YY", if user clicks between the beginning of the
label to the first "/", I only pops up "XX". Same thing if user clicks
between the first "/" and the last "/", only "MM" will pop up.
Thanks for any help.
"Eric Bordeau" <ebordeau@us.ibm.com> wrote in message
news:b09ncg$hvk$1@rogue.oti.com...
> Yes, DirectEditRequest is now a subclass of LocationRequest.
>
> Eric
>
> Hal wrote:
> > Hi,
> >
> > Couple months ago I post a message about how to make label to have
several
> > editable parts. Randy Hudson, that can be done if a simple change is
made in
> > GEF. Would you please tell me if that change is in the latest build?
> >
> > Thank you.
> >
> > Subject: Re: Make Label to have serval editable parts?
> > From: hudsonr@us.eye-bee-em.com (Randy Hudson)
> > Newsgroups: eclipse.tools.gef
> > Organization: EclipseCorner
> > Date: Oct 09 2002 20:24:13
> >
> > If we make a simple change in GEF (SelectEditPartTracker), Hal could use
> > this figure with a single editpart. The change would be to make "direct
> > edit" a LocationRequest. Hal could just take the Request and compare
its
> > location to the location of the 3 labels.
> >
> > However, both of these solution only work with the mouse. You would
still
> > have to figure out how to switch between the 3 CellEditors with the
> > keyboard.
> >
> >
> >
> >>>public void performRequest(Request request) {
> >>>if (request.getType() == RequestConstants.REQ_DIRECT_EDIT) {
> >
> >
> > Point where = ((LocationRequest)request).getLocation(); //Returns
the
> > location on the Canvas
> > getMonthLabel().translateToRelative(where); //You could use any of
the
> > 3 labels for this translation
> > if (getMonthLabel().containsPoint(where)){
> > performMonthDirectEdit();
> > } else if ...
> > //etc.
> >
> >
> >>>}
> >>>}
> >
> >
> >
> >
> >
> >
> >
> >
> >
>
|
|
|
Re: Make Label to have several editable parts? [message #56065 is a reply to message #56035] |
Sat, 18 January 2003 21:23 |
Eric Bordeau Messages: 259 Registered: July 2009 |
Senior Member |
|
|
Hal,
Direct edit happens during SelectEditPartTracker.performDirectEdit(), which calls
performRequest(Request) on your EditPart. The location I printed out in this method changed when I
clicked on different places on the LogicLabel. Is this where you're getting the incoming request?
Are you creating a new manager for each direct edit or are you caching the manager somewhere in
between direct edits? Try stepping through the performRequest(Request) in your EditPart and make
sure the location is being updated properly in your DirectEditManager.
Hope this helps.
Eric
Hal wrote:
> Thanks. I try this, but the getLocation() always return me the *SAME*
> co-ordinate regardless where I click on the label.
>
> Here is what I did:
> - create a new LocationEditManager and in its createDirectEditRequest(),
> copy the location from the incoming directEditRequest to this new Direct
> edit request that it is going to create.
> protected DirectEditRequest createDirectEditRequest(){
>
> DirectEditRequest req = new DirectEditRequest();
>
>
> if (request != null){
>
> req.setLocation(incomingDirectEditRequest.getLocation());
>
> }
>
>
> req.setCellEditor(getCellEditor());
>
> return req;
>
> }
>
> - create a new DirectEditPolicy, I print out the location of the request:
> But the location is ALWAYS the same, regardless where I click the label:
> protected void showCurrentEditValue(DirectEditRequest request) {
>
> System.out.println ("showCurrentEditValue x:" + request.getLocation().x + "
> y:" + request.getLocation().y);
>
> LogicSubpart host =
> (LogicSubpart)((AbstractGraphicalEditPart)getHost()).getMode l();
>
> //...
>
> }
>
> - in my editPart, I install this new direct edit policy and create my new
> directEditManager when necessary.
>
> Could you please if I miss anything? What I want to do is I have a label
> looks like this "XX / MM / YY", if user clicks between the beginning of the
> label to the first "/", I only pops up "XX". Same thing if user clicks
> between the first "/" and the last "/", only "MM" will pop up.
>
> Thanks for any help.
>
>
>
>
> "Eric Bordeau" <ebordeau@us.ibm.com> wrote in message
> news:b09ncg$hvk$1@rogue.oti.com...
>
>>Yes, DirectEditRequest is now a subclass of LocationRequest.
>>
>>Eric
>>
>>Hal wrote:
>>
>>>Hi,
>>>
>>>Couple months ago I post a message about how to make label to have
>
> several
>
>>>editable parts. Randy Hudson, that can be done if a simple change is
>
> made in
>
>>>GEF. Would you please tell me if that change is in the latest build?
>>>
>>>Thank you.
>>>
>>> Subject: Re: Make Label to have serval editable parts?
>>>From: hudsonr@us.eye-bee-em.com (Randy Hudson)
>>>Newsgroups: eclipse.tools.gef
>>>Organization: EclipseCorner
>>>Date: Oct 09 2002 20:24:13
>>>
>>>If we make a simple change in GEF (SelectEditPartTracker), Hal could use
>>>this figure with a single editpart. The change would be to make "direct
>>>edit" a LocationRequest. Hal could just take the Request and compare
>
> its
>
>>>location to the location of the 3 labels.
>>>
>>>However, both of these solution only work with the mouse. You would
>
> still
>
>>>have to figure out how to switch between the 3 CellEditors with the
>>>keyboard.
>>>
>>>
>>>
>>>
>>>>>public void performRequest(Request request) {
>>>>>if (request.getType() == RequestConstants.REQ_DIRECT_EDIT) {
>>>
>>>
>>> Point where = ((LocationRequest)request).getLocation(); //Returns
>
> the
>
>>>location on the Canvas
>>> getMonthLabel().translateToRelative(where); //You could use any of
>
> the
>
>>>3 labels for this translation
>>> if (getMonthLabel().containsPoint(where)){
>>> performMonthDirectEdit();
>>> } else if ...
>>> //etc.
>>>
>>>
>>>
>>>>>}
>>>>>}
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>
>
>
|
|
|
Re: Make Label to have several editable parts? [message #56092 is a reply to message #56065] |
Sat, 18 January 2003 22:39 |
Hal Messages: 67 Registered: July 2009 |
Member |
|
|
Thanks, I will try that.
Another question that I have is the co-ordinate I get is absolute, how can
I get it with respective to the beginning of the label?
"Eric Bordeau" <ebordeau@us.ibm.com> wrote in message
news:b0cfjh$hdp$1@rogue.oti.com...
> Hal,
>
> Direct edit happens during SelectEditPartTracker.performDirectEdit(),
which calls
> performRequest(Request) on your EditPart. The location I printed out in
this method changed when I
> clicked on different places on the LogicLabel. Is this where you're
getting the incoming request?
> Are you creating a new manager for each direct edit or are you caching the
manager somewhere in
> between direct edits? Try stepping through the performRequest(Request) in
your EditPart and make
> sure the location is being updated properly in your DirectEditManager.
>
> Hope this helps.
>
> Eric
>
>
> Hal wrote:
> > Thanks. I try this, but the getLocation() always return me the *SAME*
> > co-ordinate regardless where I click on the label.
> >
> > Here is what I did:
> > - create a new LocationEditManager and in its createDirectEditRequest(),
> > copy the location from the incoming directEditRequest to this new Direct
> > edit request that it is going to create.
> > protected DirectEditRequest createDirectEditRequest(){
> >
> > DirectEditRequest req = new DirectEditRequest();
> >
> >
> > if (request != null){
> >
> > req.setLocation(incomingDirectEditRequest.getLocation());
> >
> > }
> >
> >
> > req.setCellEditor(getCellEditor());
> >
> > return req;
> >
> > }
> >
> > - create a new DirectEditPolicy, I print out the location of the
request:
> > But the location is ALWAYS the same, regardless where I click the label:
> > protected void showCurrentEditValue(DirectEditRequest request) {
> >
> > System.out.println ("showCurrentEditValue x:" + request.getLocation().x
+ "
> > y:" + request.getLocation().y);
> >
> > LogicSubpart host =
> > (LogicSubpart)((AbstractGraphicalEditPart)getHost()).getMode l();
> >
> > //...
> >
> > }
> >
> > - in my editPart, I install this new direct edit policy and create my
new
> > directEditManager when necessary.
> >
> > Could you please if I miss anything? What I want to do is I have a label
> > looks like this "XX / MM / YY", if user clicks between the beginning of
the
> > label to the first "/", I only pops up "XX". Same thing if user clicks
> > between the first "/" and the last "/", only "MM" will pop up.
> >
> > Thanks for any help.
> >
> >
> >
> >
> > "Eric Bordeau" <ebordeau@us.ibm.com> wrote in message
> > news:b09ncg$hvk$1@rogue.oti.com...
> >
> >>Yes, DirectEditRequest is now a subclass of LocationRequest.
> >>
> >>Eric
> >>
> >>Hal wrote:
> >>
> >>>Hi,
> >>>
> >>>Couple months ago I post a message about how to make label to have
> >
> > several
> >
> >>>editable parts. Randy Hudson, that can be done if a simple change is
> >
> > made in
> >
> >>>GEF. Would you please tell me if that change is in the latest build?
> >>>
> >>>Thank you.
> >>>
> >>> Subject: Re: Make Label to have serval editable parts?
> >>>From: hudsonr@us.eye-bee-em.com (Randy Hudson)
> >>>Newsgroups: eclipse.tools.gef
> >>>Organization: EclipseCorner
> >>>Date: Oct 09 2002 20:24:13
> >>>
> >>>If we make a simple change in GEF (SelectEditPartTracker), Hal could
use
> >>>this figure with a single editpart. The change would be to make
"direct
> >>>edit" a LocationRequest. Hal could just take the Request and compare
> >
> > its
> >
> >>>location to the location of the 3 labels.
> >>>
> >>>However, both of these solution only work with the mouse. You would
> >
> > still
> >
> >>>have to figure out how to switch between the 3 CellEditors with the
> >>>keyboard.
> >>>
> >>>
> >>>
> >>>
> >>>>>public void performRequest(Request request) {
> >>>>>if (request.getType() == RequestConstants.REQ_DIRECT_EDIT) {
> >>>
> >>>
> >>> Point where = ((LocationRequest)request).getLocation(); //Returns
> >
> > the
> >
> >>>location on the Canvas
> >>> getMonthLabel().translateToRelative(where); //You could use any of
> >
> > the
> >
> >>>3 labels for this translation
> >>> if (getMonthLabel().containsPoint(where)){
> >>> performMonthDirectEdit();
> >>> } else if ...
> >>> //etc.
> >>>
> >>>
> >>>
> >>>>>}
> >>>>>}
> >>>
> >>>
> >>>
> >>>
> >>>
> >>>
> >>>
> >>>
> >>>
> >
> >
> >
>
|
|
|
Re: Make Label to have several editable parts? [message #56169 is a reply to message #56092] |
Sun, 19 January 2003 07:08 |
Eric Bordeau Messages: 259 Registered: July 2009 |
Senior Member |
|
|
Calling label.translateToRelative(point) will give you that point relative to the label's coordinate
system.
Hal wrote:
> Thanks, I will try that.
> Another question that I have is the co-ordinate I get is absolute, how can
> I get it with respective to the beginning of the label?
>
>
> "Eric Bordeau" <ebordeau@us.ibm.com> wrote in message
> news:b0cfjh$hdp$1@rogue.oti.com...
>
>>Hal,
>>
>>Direct edit happens during SelectEditPartTracker.performDirectEdit(),
>
> which calls
>
>>performRequest(Request) on your EditPart. The location I printed out in
>
> this method changed when I
>
>>clicked on different places on the LogicLabel. Is this where you're
>
> getting the incoming request?
>
>>Are you creating a new manager for each direct edit or are you caching the
>
> manager somewhere in
>
>>between direct edits? Try stepping through the performRequest(Request) in
>
> your EditPart and make
>
>>sure the location is being updated properly in your DirectEditManager.
>>
>>Hope this helps.
>>
>>Eric
>>
>>
>>Hal wrote:
>>
>>>Thanks. I try this, but the getLocation() always return me the *SAME*
>>>co-ordinate regardless where I click on the label.
>>>
>>>Here is what I did:
>>>- create a new LocationEditManager and in its createDirectEditRequest(),
>>>copy the location from the incoming directEditRequest to this new Direct
>>>edit request that it is going to create.
>>>protected DirectEditRequest createDirectEditRequest(){
>>>
>>>DirectEditRequest req = new DirectEditRequest();
>>>
>>>
>>>if (request != null){
>>>
>>>req.setLocation(incomingDirectEditRequest.getLocation());
>>>
>>>}
>>>
>>>
>>>req.setCellEditor(getCellEditor());
>>>
>>>return req;
>>>
>>>}
>>>
>>>- create a new DirectEditPolicy, I print out the location of the
>
> request:
>
>>>But the location is ALWAYS the same, regardless where I click the label:
>>>protected void showCurrentEditValue(DirectEditRequest request) {
>>>
>>>System.out.println ("showCurrentEditValue x:" + request.getLocation().x
>
> + "
>
>>>y:" + request.getLocation().y);
>>>
>>>LogicSubpart host =
>>> (LogicSubpart)((AbstractGraphicalEditPart)getHost()).getMode l();
>>>
>>>//...
>>>
>>>}
>>>
>>>- in my editPart, I install this new direct edit policy and create my
>
> new
>
>>>directEditManager when necessary.
>>>
>>>Could you please if I miss anything? What I want to do is I have a label
>>>looks like this "XX / MM / YY", if user clicks between the beginning of
>
> the
>
>>>label to the first "/", I only pops up "XX". Same thing if user clicks
>>>between the first "/" and the last "/", only "MM" will pop up.
>>>
>>>Thanks for any help.
>>>
>>>
>>>
>>>
>>>"Eric Bordeau" <ebordeau@us.ibm.com> wrote in message
>>>news:b09ncg$hvk$1@rogue.oti.com...
>>>
>>>
>>>>Yes, DirectEditRequest is now a subclass of LocationRequest.
>>>>
>>>>Eric
>>>>
>>>>Hal wrote:
>>>>
>>>>
>>>>>Hi,
>>>>>
>>>>>Couple months ago I post a message about how to make label to have
>>>
>>>several
>>>
>>>
>>>>>editable parts. Randy Hudson, that can be done if a simple change is
>>>
>>>made in
>>>
>>>
>>>>>GEF. Would you please tell me if that change is in the latest build?
>>>>>
>>>>>Thank you.
>>>>>
>>>>>Subject: Re: Make Label to have serval editable parts?
>>>>>From: hudsonr@us.eye-bee-em.com (Randy Hudson)
>>>>>Newsgroups: eclipse.tools.gef
>>>>>Organization: EclipseCorner
>>>>>Date: Oct 09 2002 20:24:13
>>>>>
>>>>>If we make a simple change in GEF (SelectEditPartTracker), Hal could
>
> use
>
>>>>>this figure with a single editpart. The change would be to make
>
> "direct
>
>>>>>edit" a LocationRequest. Hal could just take the Request and compare
>>>
>>>its
>>>
>>>
>>>>>location to the location of the 3 labels.
>>>>>
>>>>>However, both of these solution only work with the mouse. You would
>>>
>>>still
>>>
>>>
>>>>>have to figure out how to switch between the 3 CellEditors with the
>>>>>keyboard.
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>>>public void performRequest(Request request) {
>>>>>>>if (request.getType() == RequestConstants.REQ_DIRECT_EDIT) {
>>>>>
>>>>>
>>>>> Point where = ((LocationRequest)request).getLocation(); //Returns
>>>
>>>the
>>>
>>>
>>>>>location on the Canvas
>>>>> getMonthLabel().translateToRelative(where); //You could use any of
>>>
>>>the
>>>
>>>
>>>>>3 labels for this translation
>>>>> if (getMonthLabel().containsPoint(where)){
>>>>> performMonthDirectEdit();
>>>>> } else if ...
>>>>> //etc.
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>>>}
>>>>>>>}
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>
>>>
>
>
|
|
|
Re: Make Label to have several editable parts? [message #57944 is a reply to message #56169] |
Fri, 24 January 2003 22:11 |
Hal Messages: 67 Registered: July 2009 |
Member |
|
|
Eric,
Thanks for your response.
I print out the value of the co-ordinate of the request location (before and
after calling translateToRelative()),
but I don't understand is why X is 39 and Y is 27 after I
translateToRelative()? From the 3rd result, the width of the host is 24 and
height is 13, so X should be 0 < x < 24 and Y should be 0 < y < 13 right?
how come x is 39 and y is 27?
Before x:188 y:163
After x:39 y:27
host.x:0 host.y:0 host.width:24 host.height:13
<< the code>>
Point location = request.getLocation();
System.out.println ("Before x:" + location.x + " y:" + location.y);
LogicSubpart host =
(LogicSubpart)((AbstractGraphicalEditPart)getHost()).getMode l();
IFigure figure = ((AbstractGraphicalEditPart)getHost()).getFigure();
figure.translateToRelative(location);
System.out.println ("After x:" + location.x + " y:" + location.y);
System.out.println (" host.x:" + host.getLocation().x + " host.y:" +
host.getLocation().y + " host.width:" + host.getSize().width + "
host.height:" + host.getSize().height);
"Eric Bordeau" <ebordeau@us.ibm.com> wrote in message
news:b0dhro$hdp$2@rogue.oti.com...
> Calling label.translateToRelative(point) will give you that point relative
to the label's coordinate
> system.
>
>
> Hal wrote:
> > Thanks, I will try that.
> > Another question that I have is the co-ordinate I get is absolute, how
can
> > I get it with respective to the beginning of the label?
> >
> >
> > "Eric Bordeau" <ebordeau@us.ibm.com> wrote in message
> > news:b0cfjh$hdp$1@rogue.oti.com...
> >
> >>Hal,
> >>
> >>Direct edit happens during SelectEditPartTracker.performDirectEdit(),
> >
> > which calls
> >
> >>performRequest(Request) on your EditPart. The location I printed out in
> >
> > this method changed when I
> >
> >>clicked on different places on the LogicLabel. Is this where you're
> >
> > getting the incoming request?
> >
> >>Are you creating a new manager for each direct edit or are you caching
the
> >
> > manager somewhere in
> >
> >>between direct edits? Try stepping through the performRequest(Request)
in
> >
> > your EditPart and make
> >
> >>sure the location is being updated properly in your DirectEditManager.
> >>
> >>Hope this helps.
> >>
> >>Eric
> >>
> >>
> >>Hal wrote:
> >>
> >>>Thanks. I try this, but the getLocation() always return me the *SAME*
> >>>co-ordinate regardless where I click on the label.
> >>>
> >>>Here is what I did:
> >>>- create a new LocationEditManager and in its
createDirectEditRequest(),
> >>>copy the location from the incoming directEditRequest to this new
Direct
> >>>edit request that it is going to create.
> >>>protected DirectEditRequest createDirectEditRequest(){
> >>>
> >>>DirectEditRequest req = new DirectEditRequest();
> >>>
> >>>
> >>>if (request != null){
> >>>
> >>>req.setLocation(incomingDirectEditRequest.getLocation());
> >>>
> >>>}
> >>>
> >>>
> >>>req.setCellEditor(getCellEditor());
> >>>
> >>>return req;
> >>>
> >>>}
> >>>
> >>>- create a new DirectEditPolicy, I print out the location of the
> >
> > request:
> >
> >>>But the location is ALWAYS the same, regardless where I click the
label:
> >>>protected void showCurrentEditValue(DirectEditRequest request) {
> >>>
> >>>System.out.println ("showCurrentEditValue x:" + request.getLocation().x
> >
> > + "
> >
> >>>y:" + request.getLocation().y);
> >>>
> >>>LogicSubpart host =
> >>> (LogicSubpart)((AbstractGraphicalEditPart)getHost()).getMode l();
> >>>
> >>>//...
> >>>
> >>>}
> >>>
> >>>- in my editPart, I install this new direct edit policy and create my
> >
> > new
> >
> >>>directEditManager when necessary.
> >>>
> >>>Could you please if I miss anything? What I want to do is I have a
label
> >>>looks like this "XX / MM / YY", if user clicks between the beginning of
> >
> > the
> >
> >>>label to the first "/", I only pops up "XX". Same thing if user clicks
> >>>between the first "/" and the last "/", only "MM" will pop up.
> >>>
> >>>Thanks for any help.
> >>>
> >>>
> >>>
> >>>
> >>>"Eric Bordeau" <ebordeau@us.ibm.com> wrote in message
> >>>news:b09ncg$hvk$1@rogue.oti.com...
> >>>
> >>>
> >>>>Yes, DirectEditRequest is now a subclass of LocationRequest.
> >>>>
> >>>>Eric
> >>>>
> >>>>Hal wrote:
> >>>>
> >>>>
> >>>>>Hi,
> >>>>>
> >>>>>Couple months ago I post a message about how to make label to have
> >>>
> >>>several
> >>>
> >>>
> >>>>>editable parts. Randy Hudson, that can be done if a simple change is
> >>>
> >>>made in
> >>>
> >>>
> >>>>>GEF. Would you please tell me if that change is in the latest build?
> >>>>>
> >>>>>Thank you.
> >>>>>
> >>>>>Subject: Re: Make Label to have serval editable parts?
> >>>>>From: hudsonr@us.eye-bee-em.com (Randy Hudson)
> >>>>>Newsgroups: eclipse.tools.gef
> >>>>>Organization: EclipseCorner
> >>>>>Date: Oct 09 2002 20:24:13
> >>>>>
> >>>>>If we make a simple change in GEF (SelectEditPartTracker), Hal could
> >
> > use
> >
> >>>>>this figure with a single editpart. The change would be to make
> >
> > "direct
> >
> >>>>>edit" a LocationRequest. Hal could just take the Request and compare
> >>>
> >>>its
> >>>
> >>>
> >>>>>location to the location of the 3 labels.
> >>>>>
> >>>>>However, both of these solution only work with the mouse. You would
> >>>
> >>>still
> >>>
> >>>
> >>>>>have to figure out how to switch between the 3 CellEditors with the
> >>>>>keyboard.
> >>>>>
> >>>>>
> >>>>>
> >>>>>
> >>>>>
> >>>>>>>public void performRequest(Request request) {
> >>>>>>>if (request.getType() == RequestConstants.REQ_DIRECT_EDIT) {
> >>>>>
> >>>>>
> >>>>> Point where = ((LocationRequest)request).getLocation(); //Returns
> >>>
> >>>the
> >>>
> >>>
> >>>>>location on the Canvas
> >>>>> getMonthLabel().translateToRelative(where); //You could use any
of
> >>>
> >>>the
> >>>
> >>>
> >>>>>3 labels for this translation
> >>>>> if (getMonthLabel().containsPoint(where)){
> >>>>> performMonthDirectEdit();
> >>>>> } else if ...
> >>>>> //etc.
> >>>>>
> >>>>>
> >>>>>
> >>>>>
> >>>>>>>}
> >>>>>>>}
> >>>>>
> >>>>>
> >>>>>
> >>>>>
> >>>>>
> >>>>>
> >>>>>
> >>>>>
> >>>>>
> >>>
> >>>
> >
> >
>
|
|
|
Re: Make Label to have several editable parts? [message #58972 is a reply to message #57944] |
Tue, 28 January 2003 21:02 |
Eclipse User |
|
|
|
Originally posted by: none.us.ibm.com
"Relative" in Draw2D means that the coordinate is relative to the figure's
bounds, not relative to it's top-left corner. This is because most figures
are positioned in absolute coordinates.
In your case, the figure's bounds were probably at something like x = 20, so
0 <= (39-20) < 24.
"Hal" <otaconss2@hotmail.com> wrote in message
news:b0sci7$olq$1@rogue.oti.com...
> Eric,
>
> Thanks for your response.
>
> I print out the value of the co-ordinate of the request location (before
and
> after calling translateToRelative()),
> but I don't understand is why X is 39 and Y is 27 after I
> translateToRelative()? From the 3rd result, the width of the host is 24
and
> height is 13, so X should be 0 < x < 24 and Y should be 0 < y < 13 right?
> how come x is 39 and y is 27?
> Before x:188 y:163
>
> After x:39 y:27
>
> host.x:0 host.y:0 host.width:24 host.height:13
>
> << the code>>
> Point location = request.getLocation();
>
> System.out.println ("Before x:" + location.x + " y:" + location.y);
>
>
>
>
>
> LogicSubpart host =
> (LogicSubpart)((AbstractGraphicalEditPart)getHost()).getMode l();
>
> IFigure figure = ((AbstractGraphicalEditPart)getHost()).getFigure();
>
>
> figure.translateToRelative(location);
>
> System.out.println ("After x:" + location.x + " y:" + location.y);
>
> System.out.println (" host.x:" + host.getLocation().x + " host.y:" +
> host.getLocation().y + " host.width:" + host.getSize().width + "
> host.height:" + host.getSize().height);
>
>
>
> "Eric Bordeau" <ebordeau@us.ibm.com> wrote in message
> news:b0dhro$hdp$2@rogue.oti.com...
> > Calling label.translateToRelative(point) will give you that point
relative
> to the label's coordinate
> > system.
> >
> >
> > Hal wrote:
> > > Thanks, I will try that.
> > > Another question that I have is the co-ordinate I get is absolute,
how
> can
> > > I get it with respective to the beginning of the label?
> > >
> > >
> > > "Eric Bordeau" <ebordeau@us.ibm.com> wrote in message
> > > news:b0cfjh$hdp$1@rogue.oti.com...
> > >
> > >>Hal,
> > >>
> > >>Direct edit happens during SelectEditPartTracker.performDirectEdit(),
> > >
> > > which calls
> > >
> > >>performRequest(Request) on your EditPart. The location I printed out
in
> > >
> > > this method changed when I
> > >
> > >>clicked on different places on the LogicLabel. Is this where you're
> > >
> > > getting the incoming request?
> > >
> > >>Are you creating a new manager for each direct edit or are you caching
> the
> > >
> > > manager somewhere in
> > >
> > >>between direct edits? Try stepping through the
performRequest(Request)
> in
> > >
> > > your EditPart and make
> > >
> > >>sure the location is being updated properly in your DirectEditManager.
> > >>
> > >>Hope this helps.
> > >>
> > >>Eric
> > >>
> > >>
> > >>Hal wrote:
> > >>
> > >>>Thanks. I try this, but the getLocation() always return me the *SAME*
> > >>>co-ordinate regardless where I click on the label.
> > >>>
> > >>>Here is what I did:
> > >>>- create a new LocationEditManager and in its
> createDirectEditRequest(),
> > >>>copy the location from the incoming directEditRequest to this new
> Direct
> > >>>edit request that it is going to create.
> > >>>protected DirectEditRequest createDirectEditRequest(){
> > >>>
> > >>>DirectEditRequest req = new DirectEditRequest();
> > >>>
> > >>>
> > >>>if (request != null){
> > >>>
> > >>>req.setLocation(incomingDirectEditRequest.getLocation());
> > >>>
> > >>>}
> > >>>
> > >>>
> > >>>req.setCellEditor(getCellEditor());
> > >>>
> > >>>return req;
> > >>>
> > >>>}
> > >>>
> > >>>- create a new DirectEditPolicy, I print out the location of the
> > >
> > > request:
> > >
> > >>>But the location is ALWAYS the same, regardless where I click the
> label:
> > >>>protected void showCurrentEditValue(DirectEditRequest request) {
> > >>>
> > >>>System.out.println ("showCurrentEditValue x:" +
request.getLocation().x
> > >
> > > + "
> > >
> > >>>y:" + request.getLocation().y);
> > >>>
> > >>>LogicSubpart host =
> > >>> (LogicSubpart)((AbstractGraphicalEditPart)getHost()).getMode l();
> > >>>
> > >>>//...
> > >>>
> > >>>}
> > >>>
> > >>>- in my editPart, I install this new direct edit policy and create my
> > >
> > > new
> > >
> > >>>directEditManager when necessary.
> > >>>
> > >>>Could you please if I miss anything? What I want to do is I have a
> label
> > >>>looks like this "XX / MM / YY", if user clicks between the beginning
of
> > >
> > > the
> > >
> > >>>label to the first "/", I only pops up "XX". Same thing if user
clicks
> > >>>between the first "/" and the last "/", only "MM" will pop up.
> > >>>
> > >>>Thanks for any help.
> > >>>
> > >>>
> > >>>
> > >>>
> > >>>"Eric Bordeau" <ebordeau@us.ibm.com> wrote in message
> > >>>news:b09ncg$hvk$1@rogue.oti.com...
> > >>>
> > >>>
> > >>>>Yes, DirectEditRequest is now a subclass of LocationRequest.
> > >>>>
> > >>>>Eric
> > >>>>
> > >>>>Hal wrote:
> > >>>>
> > >>>>
> > >>>>>Hi,
> > >>>>>
> > >>>>>Couple months ago I post a message about how to make label to have
> > >>>
> > >>>several
> > >>>
> > >>>
> > >>>>>editable parts. Randy Hudson, that can be done if a simple change
is
> > >>>
> > >>>made in
> > >>>
> > >>>
> > >>>>>GEF. Would you please tell me if that change is in the latest
build?
> > >>>>>
> > >>>>>Thank you.
> > >>>>>
> > >>>>>Subject: Re: Make Label to have serval editable parts?
> > >>>>>From: hudsonr@us.eye-bee-em.com (Randy Hudson)
> > >>>>>Newsgroups: eclipse.tools.gef
> > >>>>>Organization: EclipseCorner
> > >>>>>Date: Oct 09 2002 20:24:13
> > >>>>>
> > >>>>>If we make a simple change in GEF (SelectEditPartTracker), Hal
could
> > >
> > > use
> > >
> > >>>>>this figure with a single editpart. The change would be to make
> > >
> > > "direct
> > >
> > >>>>>edit" a LocationRequest. Hal could just take the Request and
compare
> > >>>
> > >>>its
> > >>>
> > >>>
> > >>>>>location to the location of the 3 labels.
> > >>>>>
> > >>>>>However, both of these solution only work with the mouse. You
would
> > >>>
> > >>>still
> > >>>
> > >>>
> > >>>>>have to figure out how to switch between the 3 CellEditors with the
> > >>>>>keyboard.
> > >>>>>
> > >>>>>
> > >>>>>
> > >>>>>
> > >>>>>
> > >>>>>>>public void performRequest(Request request) {
> > >>>>>>>if (request.getType() == RequestConstants.REQ_DIRECT_EDIT) {
> > >>>>>
> > >>>>>
> > >>>>> Point where = ((LocationRequest)request).getLocation();
//Returns
> > >>>
> > >>>the
> > >>>
> > >>>
> > >>>>>location on the Canvas
> > >>>>> getMonthLabel().translateToRelative(where); //You could use any
> of
> > >>>
> > >>>the
> > >>>
> > >>>
> > >>>>>3 labels for this translation
> > >>>>> if (getMonthLabel().containsPoint(where)){
> > >>>>> performMonthDirectEdit();
> > >>>>> } else if ...
> > >>>>> //etc.
> > >>>>>
> > >>>>>
> > >>>>>
> > >>>>>
> > >>>>>>>}
> > >>>>>>>}
> > >>>>>
> > >>>>>
> > >>>>>
> > >>>>>
> > >>>>>
> > >>>>>
> > >>>>>
> > >>>>>
> > >>>>>
> > >>>
> > >>>
> > >
> > >
> >
>
>
|
|
|
Goto Forum:
Current Time: Sat Dec 21 13:43:22 GMT 2024
Powered by FUDForum. Page generated in 0.04833 seconds
|