Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 342666

Summary: "hasFocus()" from class ShapeEditPart returns wrong result
Product: [Modeling] Graphiti Reporter: Juergen Pasch <juergen.pasch>
Component: CoreAssignee: Project Inbox <graphiti-inbox>
Status: CLOSED WORKSFORME QA Contact:
Severity: normal    
Priority: P3 CC: matthias.gorning, michael.wenz
Version: 0.8.0   
Target Milestone: ---   
Hardware: All   
OS: All   
Whiteboard:

Description Juergen Pasch CLA 2011-04-13 03:15:07 EDT
This result appeared when extending method "isSelectable()" with "hasFocus()" for testing purposes. The method delivered always false, even when the diagram editor has had focus. Note: ShapeEditPart extends gef.editparts.AbstractEditPart.
Comment 1 Matthias Gorning CLA 2011-05-13 04:59:49 EDT
For me this method works correct.

For testing the correct behaviour you can override the method "hasFocus()" in ShapeEditPart with:

	@Override
	public boolean hasFocus() {
		boolean ret = super.hasFocus();
		if (ret) {
			if (getPictogramElement().getGraphicsAlgorithm() instanceof org.eclipse.graphiti.mm.algorithms.Rectangle) {
				EList<GraphicsAlgorithm> gaChildren = getPictogramElement().getGraphicsAlgorithm().getGraphicsAlgorithmChildren();
				if (gaChildren.size() > 0 && gaChildren.get(0) instanceof Text) {
					Text t = (Text) gaChildren.get(0);
					System.out.println("ShapeEditPart.hasFocus() " + t.getValue());
				}
			}
		}
		return ret;
	}
Comment 2 Matthias Gorning CLA 2011-05-13 05:16:02 EDT
You must test this with the sketch editor. Create some objects of type "Rectangle Single Text". Then change simply the focus between these edit parts and you will see the output in the console.
Comment 3 Michael Wenz CLA 2011-06-24 08:54:31 EDT
No bug