Location of a DirectEditRequest [message #185841] |
Thu, 30 June 2005 13:10 |
Eclipse User |
|
|
|
Originally posted by: marlu942.student.liu.se
Hi!
I'm experiencing a small problem implementing support for direct editing
in my GEF based application.
My Scenarion: I have figure consisting of several draw2D labels. I would
like to be able to DirectEdit each individual label.
Solution that does not work: The receiver of the
RequestConstants.REQ_DIRECT_EDIT request (a DirectEditPolicy) determines
depending on the location of the request which label to DirectEdit.
However, the location is NULL in the DirectEditRequest so I can not
determine where the user clicked on the figure.
Sample Code:
public class UIComponentDirectEditPolicy extends DirectEditPolicy {
public Command getCommand(Request request) {
if (RequestConstants.REQ_DIRECT_EDIT == request.getType()) {
Point location = (DirectEditRequest)request).getLocation();
System.out.println("Location for Request = " + location);
return getDirectEditCommand((DirectEditRequest) request); }
return null;
}
...
Has anyone tried to determine the location of a DirectEdit request in a
figure and know a solution?
Regards,
Marcus Ludvigson
|
|
|
|
Re: Location of a DirectEditRequest [message #185863 is a reply to message #185849] |
Thu, 30 June 2005 15:37 |
Eclipse User |
|
|
|
Originally posted by: marlu942.student.liu.se
Jason Kealey wrote:
> I admit it must be difficult to assign a location when someone presses a
> key (f2) to direct edit. Why can't you directly use the label's location?
>
True. Well, I still can't handle pressing the F2-key and probably will
not be able to handle. But I have succeded in locating my labels and
direct edit them. The key was to step in earlier and handle the request
in the EditPart instead. The EditPart receives the DirectEdit request
WITH location, so I can find out which draw2D label child of my figure
to DirectEdit.
Solution skiss:
public class UIComponentEditPart extends AbstractElementEditPart {
....
public void performRequest(Request request) {
if (request.getType() == RequestConstants.REQ_DIRECT_EDIT){
performDirectEdit(((DirectEditRequest)request).getLocation() .getCopy());
}
}
protected void performDirectEdit(Point location) {
UIComponentFigures fig = (UIComponentFigures) getFigure();
fig.translateToRelative(location);
IFigure directEditFigure = fig.findFigureAt(location);
if (directEditFigure != null && directEditFigure instanceof
DirectEditLabel){
DirectEditManager directEditManager =
new UIComponentDirectEditManager(
this,
TextCellEditor.class,
new UIComponentCellEditorLocator((DirectEditLabel)directEditFigu re),
fig);
directEditManager.show();
}
}
...
I hope this helps someone else.
Regards,
Marcus Ludvigson
|
|
|
Re: Location of a DirectEditRequest [message #186527 is a reply to message #185841] |
Tue, 05 July 2005 18:45 |
Eclipse User |
|
|
|
Originally posted by: none.us.ibm.com
If the user invokes direct edit with the mouse, the location should be set.
If this is not hte case open a bugzilla.
"Marcus Ludvigson" <marlu942@student.liu.se> wrote in message
news:da0qvg$hfc$1@news.eclipse.org...
> Hi!
>
> I'm experiencing a small problem implementing support for direct editing
> in my GEF based application.
>
> My Scenarion: I have figure consisting of several draw2D labels. I would
> like to be able to DirectEdit each individual label.
>
> Solution that does not work: The receiver of the
> RequestConstants.REQ_DIRECT_EDIT request (a DirectEditPolicy) determines
> depending on the location of the request which label to DirectEdit.
> However, the location is NULL in the DirectEditRequest so I can not
> determine where the user clicked on the figure.
>
> Sample Code:
>
> public class UIComponentDirectEditPolicy extends DirectEditPolicy {
>
> public Command getCommand(Request request) {
> if (RequestConstants.REQ_DIRECT_EDIT == request.getType()) {
> Point location = (DirectEditRequest)request).getLocation();
> System.out.println("Location for Request = " + location);
> return getDirectEditCommand((DirectEditRequest) request); }
> return null;
> }
> ..
>
> Has anyone tried to determine the location of a DirectEdit request in a
> figure and know a solution?
>
> Regards,
> Marcus Ludvigson
>
>
|
|
|
Powered by
FUDForum. Page generated in 0.02749 seconds