Home » Eclipse Projects » GEF » Make Label to have serval editable parts?
Make Label to have serval editable parts? [message #26934] |
Wed, 09 October 2002 17:15  |
Eclipse User |
|
|
|
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 18:03   |
Eclipse User |
|
|
|
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 #27172 is a reply to message #26974] |
Thu, 10 October 2002 02:10   |
Eclipse User |
|
|
|
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 #28356 is a reply to message #27172] |
Thu, 10 October 2002 10:59   |
Eclipse User |
|
|
|
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 11:58  |
Eclipse User |
|
|
|
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.
>
> > > }
> > > }
>
>
>
|
|
|
Goto Forum:
Current Time: Mon Apr 28 02:00:43 EDT 2025
Powered by FUDForum. Page generated in 0.04134 seconds
|