Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » Graphiti » Highlighting of Anchors(My anchors don't get highlighted when hovering with the connection tool)
Highlighting of Anchors [message #1334680] Mon, 05 May 2014 18:01 Go to next message
Hernan Gonzalez is currently offline Hernan Gonzalez
Messages: 181
Registered: October 2010
Location: Buenos Aires, Argentina
Senior Member
I'm migrating/merging to the current Graphiti HEAD from an custom branch originally I forked about two years ago. Almost all is going quite smoothly, except for highlit of anchors during connection creation.

Some related issues
https://bugs.eclipse.org/bugs/show_bug.cgi?id=363186
https://bugs.eclipse.org/bugs/show_bug.cgi?id=329517

I'm still struggling to understand how it's supposed to (currently) work. I understand that
XToolBehaviorProvider.getSelectionInfoForAnchor()
is supposed to be called when hovering... but it doesn't.

Specifically, I get the tutorial code and its TutorialToolBehaviorProvider
(overriding the getSelectionInfoFor* to log the callings) and I get that only
getSelectionInfoForShape() is called, not getSelectionInfoForAnchor or
getSelectionInfoForConnection

My questions then, for now, are:

- When are those functions supposed to be called? (their docs don't say more that then method names) - and their names suggest they are called when the shape is selected ("selection info"), but they are also called for hovering?

- It's ok that in the tutorial they don't get called?

- Is there some example that show how to highlit anchors on connection creation (source or target)?

If this helps: I see that in my old working code, the highlit-on-hovering was triggered by GFAbstractShape.adaptBackgroundToHover(), but now (in the tutorial) when I hover with the Connection (EReference) over the anchor (and the connection tool pointer changes to "enabled") the method is only called with the value getHoverFeedback() = IVisualState.HOVER_OFF - and hence nothing happens. I'm not sure if this is correct behaviour.

[Updated on: Mon, 05 May 2014 18:56]

Report message to a moderator

Re: Highlighting of Anchors [message #1334751 is a reply to message #1334680] Mon, 05 May 2014 18:44 Go to previous messageGo to next message
Hernan Gonzalez is currently offline Hernan Gonzalez
Messages: 181
Registered: October 2010
Location: Buenos Aires, Argentina
Senior Member
One thing I've noticed: (still not enough for me) is that the "new" (for me) AdvancedAnchorEditPart that seems to have replaced the AnchorEditPart and its subclases, does not override the methods eraseSourceFeedback showTargetFeedback and similar, while the old AnchorEditPart did thus:

	@Override
	public void eraseSourceFeedback(Request request) {
		super.eraseSourceFeedback(request);
		delegate.getVisualState().setHoverFeedback(IVisualState.HOVER_OFF);
	}

	@Override
	public void eraseTargetFeedback(Request request) {
		super.eraseTargetFeedback(request);
		delegate.getVisualState().setHoverFeedback(IVisualState.HOVER_OFF);
	}

	@Override
	public void showSourceFeedback(Request request) {
		super.showSourceFeedback(request);
		delegate.getVisualState().setHoverFeedback(IVisualState.HOVER_ON);
	}

	@Override
	public void showTargetFeedback(Request request) {
		super.showTargetFeedback(request);
		delegate.getVisualState().setHoverFeedback(IVisualState.HOVER_ON);
	}  


Is this OK?
Re: Highlighting of Anchors [message #1334836 is a reply to message #1334751] Mon, 05 May 2014 19:31 Go to previous messageGo to next message
Hernan Gonzalez is currently offline Hernan Gonzalez
Messages: 181
Registered: October 2010
Location: Buenos Aires, Argentina
Senior Member
Another difference is that the old GFAbstractShape.adaptBackgroundToHover() considered anchors, while the current one doesn't:

Current

private boolean adaptBackgroundToHover(Graphics graphics) {
  if (getVisualState().getHoverFeedback() == IVisualState.HOVER_ON) {
    ...
    if (!(pe instanceof org.eclipse.graphiti.mm.pictograms.Shape))
      return false;
    org.eclipse.graphiti.mm.pictograms.Shape s = (org.eclipse.graphiti.mm.pictograms.Shape) pe;
    ISelectionInfo selectionInfo = tbp.getSelectionInfoForShape(s);
    
    IColorConstant hoverColor = null;
    ...
  }
}


OLD

private boolean adaptBackgroundToHover(Graphics graphics) {
  if (getVisualState().getHoverFeedback() == IVisualState.HOVER_ON) {
    ...
    ISelectionInfo selectionInfo = null;
    if (pe instanceof org.eclipse.graphiti.mm.pictograms.Shape)
      selectionInfo = tbp.getSelectionInfoForShape((org.eclipse.graphiti.mm.pictograms.Shape) pe);
    else if (pe instanceof org.eclipse.graphiti.mm.pictograms.Anchor)
      selectionInfo = tbp.getSelectionInfoForAnchor((org.eclipse.graphiti.mm.pictograms.Anchor) pe);
    else
      return false;

    IColorConstant hoverColor = null;
    ...
 }
}



If I replace the current lines by the older ones (and add the changes of the previous post to AdvancedAnchorEditPart) I get my desired behaviour.

Again, I don't know if this is right.

[Updated on: Mon, 05 May 2014 19:41]

Report message to a moderator

Re: Highlighting of Anchors [message #1339122 is a reply to message #1334680] Wed, 07 May 2014 14:29 Go to previous messageGo to next message
Hernan Gonzalez is currently offline Hernan Gonzalez
Messages: 181
Registered: October 2010
Location: Buenos Aires, Argentina
Senior Member
As I said above, I'm not sure if there were valid reasons for having removed the Anchors from the valid targets for GFAbstractShape.adaptBackgroundToHover() , so I'm unsure about filling a bug for this.

Anyway, I suggest to include the following to the tutorial


TutorialToolBehaviorProvider :
	/**
	 * Highlight of anchors
	 */
	@Override
	public IAnchorSelectionInfo getSelectionInfoForAnchor(Anchor anchor) {
		IAnchorSelectionInfo si = super.getSelectionInfoForAnchor(anchor);
		si.setHoverColor(IColorConstant.DARK_BLUE);
		si.setHoverColorParentSelected(si.getHoverColor());
		return si;
	}


This is not only a useful contribution for the tutorial, but also shows the issue.

With the current master branch, nothing happens. With my two fixes ( GFAbstractShape.adaptBackgroundToHover() + AdvancedAnchorEditPart ) it works as expected. Or at least, as I'd expect Smile
Re: Highlighting of Anchors [message #1341524 is a reply to message #1339122] Thu, 08 May 2014 14:23 Go to previous messageGo to next message
Michael Wenz is currently offline Michael Wenz
Messages: 1595
Registered: July 2009
Location: Walldorf, Germany
Senior Member
Hernan,

that is at least strange and I what I can say without haveing a detailed
look into the coding, I'd guess this is an oversight in the new
implementation and a gap.

Could you please file a bug for this and provide the code snippets there?
That is also a requirenent of the Eclipse IP process to allow us to use your
coding.

Thanks,
Michael
Re: Highlighting of Anchors [message #1341659 is a reply to message #1341524] Thu, 08 May 2014 15:39 Go to previous message
Hernan Gonzalez is currently offline Hernan Gonzalez
Messages: 181
Registered: October 2010
Location: Buenos Aires, Argentina
Senior Member
Done

https://bugs.eclipse.org/bugs/show_bug.cgi?id=434436

Previous Topic:Property Sheet & Buttons
Next Topic:View Menu: Grid and SnapToGeometry entries
Goto Forum:
  


Current Time: Wed Sep 17 15:46:40 GMT 2014

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

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