Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » Graphiti » Scrolling / zooming programmatically
Scrolling / zooming programmatically [message #725212] Wed, 14 September 2011 09:12 Go to next message
Andreas Graf is currently offline Andreas GrafFriend
Messages: 211
Registered: July 2009
Senior Member
Hi,

I am setting the selection programmatically, which works fine. However, I want to make sure that all selected elements are visible. Is there a way to programmatically scroll / zoom the diagram in the editor?

Thanks,

Andreas
Re: Scrolling / zooming programmatically [message #725214 is a reply to message #725212] Wed, 14 September 2011 09:14 Go to previous messageGo to next message
Jos Warmer is currently offline Jos WarmerFriend
Messages: 114
Registered: October 2010
Senior Member
Andreas,

I have set the selection programmatically as well. In my case Graphiti automatically scrolls the diagram to make the selected element visible. I did this for a single selection only. Doesn't this work for you? If so, how do you program the selection?

Jos
Re: Scrolling / zooming programmatically [message #725245 is a reply to message #725214] Wed, 14 September 2011 11:10 Go to previous messageGo to next message
Andreas Graf is currently offline Andreas GrafFriend
Messages: 211
Registered: July 2009
Senior Member
Hi Jos,

here is my code:

 public void execute(ICustomContext context) {
    	
    	PictogramElement[] pes = context.getPictogramElements();
    	
    	if (pes != null && pes.length == 1) {

           PictogramElement pe = pes[0];
           if(pe instanceof Connection)
           {
        	   Anchor sa = ((Connection) pe).getStart();
        	   Anchor se = ((Connection) pe).getEnd();
        	  
        	   getFeatureProvider().getDiagramTypeProvider().getDiagramEditor().selectPictogramElements(new PictogramElement[] {
        			   sa.getParent(),
        			   se.getParent()
        	   });
           }
    	}
    }

(I am selecting the peers of a connection).

However, there is no scrolling in this case. (see attached screenshot).

If I reverse the order of pictogram elements, (se.getParent(), sa.getParent()) I see some scrolling. I guess it depends on primary / secondary selection?.

Regards,

Andreas

Re: Scrolling / zooming programmatically [message #725261 is a reply to message #725245] Wed, 14 September 2011 11:37 Go to previous messageGo to next message
Jos Warmer is currently offline Jos WarmerFriend
Messages: 114
Registered: October 2010
Senior Member
Ok, I have done this in a very different way. The focus I did was through the selectionChanged(IWorkbenchPart part, ISelection selection) method in the DiagramEditor class. I have subclassed this and overridden the selectionChanged method to listen to changes from other parts. The main thing is that you need a ISelection with the businessObject to be selected inside (you can create your own StruturedSelection instance for this.
My usage is different in that the selection was done in another workbench part and went through the selectionChanged(...) method of the DiagramEditor class and I always have only one element selected.

Jos
Re: Scrolling / zooming programmatically [message #725592 is a reply to message #725245] Thu, 15 September 2011 09:54 Go to previous messageGo to next message
Michael Wenz is currently offline Michael WenzFriend
Messages: 1931
Registered: July 2009
Location: Walldorf, Germany
Senior Member
Andreas,

the selection method only uses the first element in the given array, that's
what GEF allows there. So this explains the behavior you have noticed.

Michael


"Andreas Graf" schrieb im Newsbeitrag news:j4q1dq$45e$1@news.eclipse.org...

Hi Jos,

here is my code:

public void execute(ICustomContext context) {

PictogramElement[] pes = context.getPictogramElements();

if (pes != null && pes.length == 1) {

PictogramElement pe = pes[0];
if(pe instanceof Connection)
{
Anchor sa = ((Connection) pe).getStart();
Anchor se = ((Connection) pe).getEnd();

getFeatureProvider().getDiagramTypeProvider().getDiagramEditor().selectPictogramElements(new
PictogramElement[] {
sa.getParent(),
se.getParent()
});
}
}
}

(I am selecting the peers of a connection).

However, there is no scrolling in this case. (see attached screenshot).

If I reverse the order of pictogram elements, (se.getParent(),
sa.getParent()) I see some scrolling. I guess it depends on primary /
secondary selection?.

Regards,

Andreas
Re: Scrolling / zooming programmatically [message #725606 is a reply to message #725592] Thu, 15 September 2011 10:38 Go to previous message
Andreas Graf is currently offline Andreas GrafFriend
Messages: 211
Registered: July 2009
Senior Member
OK, that explains that. Would there be another way to scroll and zoom the diagram?
Previous Topic:Use emf editor property sheet page
Next Topic:boolean return value of canCreate / canMove etc.
Goto Forum:
  


Current Time: Fri Apr 26 04:53:03 GMT 2024

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

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

Back to the top