Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » GEF » Make Label to have serval editable parts?
Make Label to have serval editable parts? [message #26934] Wed, 09 October 2002 21:15 Go to next message
Hal is currently offline HalFriend
Messages: 67
Registered: July 2009
Member
Is it possible to make Label to have serval editable parts?

For example, if I have a label for Date in the format MM/DD/YY where only
MM, DD, YY is editable.

Can I make the Label so that when the user clicks anywhere within MM region,
a text cell editor will
pop up and show ONLY "MM" as its initial Value? and when he clicks within DD
region, the text cell editor will pop up and show only "DD"?

I look at the source code for LogicLabel, it create EditManager it the
performRequest() method, but the input parameter "request" does not contains
the location of the mouse click, so I can't tell which "region" of the label
the user has clicked and initial the cell editor properly


public void performRequest(Request request) {




if (request.getType() == RequestConstants.REQ_DIRECT_EDIT) {


performDirectEdit();



}

}

Thanks for any ideas.
Re: Make Label to have serval editable parts? [message #26974 is a reply to message #26934] Wed, 09 October 2002 22:03 Go to previous messageGo to next message
Eric Bordeau is currently offline Eric BordeauFriend
Messages: 259
Registered: July 2009
Senior Member
I would think the best way to do this is to have 3 editable labels with 2
separator labels as a complex figure. For instance, create a subclass of
Figure, called DateLabel (see below). I haven't tried this, so I'm not sure of
the minor details. You may want to stop the inner labels from being selected
but I'm not sure how that affects the direct edit.

Eric

import org.eclipse.draw2d.*;

import org.eclipse.draw2d.Figure;

import org.eclipse.draw2d.Label;

public class DateLabel extends Figure {

private Label monthLabel = new Label("MM"); //$NON-NLS-1$

private Label dayLabel = new Label("DD"); //$NON-NLS-1$

private Label yearLabel = new Label("YYYY"); //$NON-NLS-1$

public DateLabel() {

setLayoutManager(new FlowLayout());

add(monthLabel);

add(new Label("/")); //$NON-NLS-1$

add(dayLabel);

add(new Label("/")); //$NON-NLS-1$

add(yearLabel);

}

}


"Hal" <otaconss2@hotmail.com> wrote in message
news:ao24sa$bbb$1@rogue.oti.com...
> Is it possible to make Label to have serval editable parts?
>
> For example, if I have a label for Date in the format MM/DD/YY where only
> MM, DD, YY is editable.
>
> Can I make the Label so that when the user clicks anywhere within MM region,
> a text cell editor will
> pop up and show ONLY "MM" as its initial Value? and when he clicks within DD
> region, the text cell editor will pop up and show only "DD"?
>
> I look at the source code for LogicLabel, it create EditManager it the
> performRequest() method, but the input parameter "request" does not contains
> the location of the mouse click, so I can't tell which "region" of the label
> the user has clicked and initial the cell editor properly
>
>
> public void performRequest(Request request) {
>
>
>
>
> if (request.getType() == RequestConstants.REQ_DIRECT_EDIT) {
>
>
> performDirectEdit();
>
>
>
> }
>
> }
>
> Thanks for any ideas.
>
>
Re: Make Label to have serval editable parts? [message #27054 is a reply to message #26974] Thu, 10 October 2002 00:24 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: hudsonr.us.eye-bee-em.com

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 serval editable parts? [message #27133 is a reply to message #27054] Thu, 10 October 2002 06:09 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: edisontooNOSPAM.yahoo.com.sg

Hi, Randy

I support your suggestion to make "direct edit" a LocationRequest. This
allows a larger container EditPart to handle direct edit more
intelligently. The alternatively to be to create many small EditPart
like the LogicLabelEditPart.

To me, I'd like to keep the number of classes and object creations to a
minimum. As it is, I'm already starting to worrry about the number of
objects being created in a typical edit session. Just count the number
of EditPart in realatively large diagram. Add the number of edit
policies (average 2-3 per editpart) and the number really starts to
escalate.

Hope this LocationRequest thing gets implemented.

Cheers,
Edison

Randy Hudson wrote:
> 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.
Re: Make Label to have serval editable parts? [message #27172 is a reply to message #26974] Thu, 10 October 2002 06:10 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: sy_cheung2.yahoo.com

Thanks. Isn't it true that I need to create a LogicLabel, LogicLabelEditPart
(like in logic editor example) in order to support DirectEdit? In your
example below, I am not sure how to initialize cell editor value with the
correct label content.

Thank you.

"Eric Bordeau" <ebordeau@us.ibm.com> wrote in message
news:ao27nf$cpc$1@rogue.oti.com...
> I would think the best way to do this is to have 3 editable labels with 2
> separator labels as a complex figure. For instance, create a subclass of
> Figure, called DateLabel (see below). I haven't tried this, so I'm not
sure of
> the minor details. You may want to stop the inner labels from being
selected
> but I'm not sure how that affects the direct edit.
>
> Eric
>
> import org.eclipse.draw2d.*;
>
> import org.eclipse.draw2d.Figure;
>
> import org.eclipse.draw2d.Label;
>
> public class DateLabel extends Figure {
>
> private Label monthLabel = new Label("MM"); //$NON-NLS-1$
>
> private Label dayLabel = new Label("DD"); //$NON-NLS-1$
>
> private Label yearLabel = new Label("YYYY"); //$NON-NLS-1$
>
> public DateLabel() {
>
> setLayoutManager(new FlowLayout());
>
> add(monthLabel);
>
> add(new Label("/")); //$NON-NLS-1$
>
> add(dayLabel);
>
> add(new Label("/")); //$NON-NLS-1$
>
> add(yearLabel);
>
> }
>
> }
>
>
> "Hal" <otaconss2@hotmail.com> wrote in message
> news:ao24sa$bbb$1@rogue.oti.com...
> > Is it possible to make Label to have serval editable parts?
> >
> > For example, if I have a label for Date in the format MM/DD/YY where
only
> > MM, DD, YY is editable.
> >
> > Can I make the Label so that when the user clicks anywhere within MM
region,
> > a text cell editor will
> > pop up and show ONLY "MM" as its initial Value? and when he clicks
within DD
> > region, the text cell editor will pop up and show only "DD"?
> >
> > I look at the source code for LogicLabel, it create EditManager it the
> > performRequest() method, but the input parameter "request" does not
contains
> > the location of the mouse click, so I can't tell which "region" of the
label
> > the user has clicked and initial the cell editor properly
> >
> >
> > public void performRequest(Request request) {
> >
> >
> >
> >
> > if (request.getType() == RequestConstants.REQ_DIRECT_EDIT) {
> >
> >
> > performDirectEdit();
> >
> >
> >
> > }
> >
> > }
> >
> > Thanks for any ideas.
> >
> >
>
>
Re: Make Label to have serval editable parts? [message #27719 is a reply to message #27133] Thu, 10 October 2002 06:45 Go to previous messageGo to next message
Hal is currently offline HalFriend
Messages: 67
Registered: July 2009
Member
Yeah, I would like to reduce the number of object created if possible.
Thanks.

"Edison Too" <edisontooNOSPAM@yahoo.com.sg> wrote in message
news:3DA51996.2000706@yahoo.com.sg...
> Hi, Randy
>
> I support your suggestion to make "direct edit" a LocationRequest. This
> allows a larger container EditPart to handle direct edit more
> intelligently. The alternatively to be to create many small EditPart
> like the LogicLabelEditPart.
>
> To me, I'd like to keep the number of classes and object creations to a
> minimum. As it is, I'm already starting to worrry about the number of
> objects being created in a typical edit session. Just count the number
> of EditPart in realatively large diagram. Add the number of edit
> policies (average 2-3 per editpart) and the number really starts to
> escalate.
>
> Hope this LocationRequest thing gets implemented.
>
> Cheers,
> Edison
>
> Randy Hudson wrote:
> > 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.
>
Re: Make Label to have serval editable parts? [message #28356 is a reply to message #27172] Thu, 10 October 2002 14:59 Go to previous messageGo to next message
Eric Bordeau is currently offline Eric BordeauFriend
Messages: 259
Registered: July 2009
Senior Member
Yeah, you're right. If you went this route, you'd have to have the DateEditPart
mirror the DateLabel's hierarchy (i.e. a DateEditPart would need 3 child
EditParts -- one for month, one for day, and one for year). I think Randy's
idea of making the direct edit request a LocationRequest is much easier.



"Sam Cheung" <sy_cheung2@yahoo.com> wrote in message
news:ao347b$o4p$1@rogue.oti.com...
> Thanks. Isn't it true that I need to create a LogicLabel, LogicLabelEditPart
> (like in logic editor example) in order to support DirectEdit? In your
> example below, I am not sure how to initialize cell editor value with the
> correct label content.
>
> Thank you.
>
> "Eric Bordeau" <ebordeau@us.ibm.com> wrote in message
> news:ao27nf$cpc$1@rogue.oti.com...
> > I would think the best way to do this is to have 3 editable labels with 2
> > separator labels as a complex figure. For instance, create a subclass of
> > Figure, called DateLabel (see below). I haven't tried this, so I'm not
> sure of
> > the minor details. You may want to stop the inner labels from being
> selected
> > but I'm not sure how that affects the direct edit.
> >
> > Eric
> >
> > import org.eclipse.draw2d.*;
> >
> > import org.eclipse.draw2d.Figure;
> >
> > import org.eclipse.draw2d.Label;
> >
> > public class DateLabel extends Figure {
> >
> > private Label monthLabel = new Label("MM"); //$NON-NLS-1$
> >
> > private Label dayLabel = new Label("DD"); //$NON-NLS-1$
> >
> > private Label yearLabel = new Label("YYYY"); //$NON-NLS-1$
> >
> > public DateLabel() {
> >
> > setLayoutManager(new FlowLayout());
> >
> > add(monthLabel);
> >
> > add(new Label("/")); //$NON-NLS-1$
> >
> > add(dayLabel);
> >
> > add(new Label("/")); //$NON-NLS-1$
> >
> > add(yearLabel);
> >
> > }
> >
> > }
> >
> >
> > "Hal" <otaconss2@hotmail.com> wrote in message
> > news:ao24sa$bbb$1@rogue.oti.com...
> > > Is it possible to make Label to have serval editable parts?
> > >
> > > For example, if I have a label for Date in the format MM/DD/YY where
> only
> > > MM, DD, YY is editable.
> > >
> > > Can I make the Label so that when the user clicks anywhere within MM
> region,
> > > a text cell editor will
> > > pop up and show ONLY "MM" as its initial Value? and when he clicks
> within DD
> > > region, the text cell editor will pop up and show only "DD"?
> > >
> > > I look at the source code for LogicLabel, it create EditManager it the
> > > performRequest() method, but the input parameter "request" does not
> contains
> > > the location of the mouse click, so I can't tell which "region" of the
> label
> > > the user has clicked and initial the cell editor properly
> > >
> > >
> > > public void performRequest(Request request) {
> > >
> > >
> > >
> > >
> > > if (request.getType() == RequestConstants.REQ_DIRECT_EDIT) {
> > >
> > >
> > > performDirectEdit();
> > >
> > >
> > >
> > > }
> > >
> > > }
> > >
> > > Thanks for any ideas.
> > >
> > >
> >
> >
>
>
Re: Make Label to have serval editable parts? [message #28865 is a reply to message #27054] Thu, 10 October 2002 15:58 Go to previous message
Hal is currently offline HalFriend
Messages: 67
Registered: July 2009
Member
If this is a simple change, can I make this change myself? If yes, could you
please tell me what changes I need to make?

Thank you.

"Randy Hudson" <hudsonr@us.eye-bee-em.com> wrote in message
news:ao2fv5$ggi$1@rogue.oti.com...
> 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.
>
> > > }
> > > }
>
>
>
Previous Topic:Hiding Selection during DirectEdit
Next Topic:Creating a palette
Goto Forum:
  


Current Time: Thu Apr 25 17:49:14 GMT 2024

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

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

Back to the top