Home » Eclipse Projects » GEF » Make Label to have serval editable parts?
|
Re: Make Label to have serval editable parts? [message #26974 is a reply to message #26934] |
Wed, 09 October 2002 22:03 |
Eric Bordeau 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 |
Eclipse User |
|
|
|
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 |
Eclipse User |
|
|
|
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 |
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 14:59 |
Eric Bordeau 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.
> > >
> > >
> >
> >
>
>
|
|
| |
Goto Forum:
Current Time: Thu Apr 25 17:49:14 GMT 2024
Powered by FUDForum. Page generated in 0.03464 seconds
|