Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » Graphiti » Problem with Context Menu
Problem with Context Menu [message #903444] Thu, 23 August 2012 16:34 Go to next message
Abie Ikhsan is currently offline Abie IkhsanFriend
Messages: 4
Registered: August 2012
Junior Member
Hi,
we have developed an editor using Graphiti by following tutorials and so far we are quite satisfied with the result. After implementing some features, we realize that some of them don't work very well. Features such as remove and delete can't be invoked from the context menu. Moreover, those features also don't work by pressing any key on keyboard, such as removing an object by pressing delete key. On the other hand, both remove and delete still work well if they are invoked from the context button. This issue also applied to our copy and paste feature.

We try to debug the implementation of copy and paste by printing some string to the console, and we observe that when context menu of the graphical object is invoked (by performing right click), we notice that our implementation of canCopy and copy methods doesn't invoked but the getCopyFeature method from FeatureProvider implementation class does. The Copy and Paste option on the context menu also can't be clicked. The implementation of copy methods is pretty much the same with the graphiti tutorial. Our implementation of copy feature looks like this:

public class CopyFeature extends AbstractCopyFeature {
	public CopyFeature(IFeatureProvider fp) {
		super(fp);
		System.out.println("A");	//printed on the console
	}
	
	@Override
	public boolean canCopy(ICopyContext context) {
		System.out.println("B");	//does not printed on the console
		
		final PictogramElement[] pes = context.getPictogramElements();
		if (pes == null || pes.length == 0) {
			return false;
		}

		for (PictogramElement pe : pes) {
			final Object bo = getBusinessObjectForPictogramElement(pe);
			if (!(bo instanceof Node)) {
				return false;
			}
		}
		
		return true;
	}

	@Override
	public void copy(ICopyContext context) {
		System.out.println("C");	//does not printed on the console
		PictogramElement[] pes = context.getPictogramElements();
        Object[] bos = new Object[pes.length ];
        for (int i = 0; i < pes.length ; i++) {
            PictogramElement pe = pes[i];
            bos[i] = getBusinessObjectForPictogramElement(pe);
        }
        
        putToClipboard(bos);
	}
}


It seems that we miss some steps to make it work, but we have no more idea. Any help is appreciated.

[Updated on: Thu, 23 August 2012 16:51]

Report message to a moderator

Re: Problem with Context Menu [message #903520 is a reply to message #903444] Fri, 24 August 2012 06:20 Go to previous messageGo to next message
Christian Brand is currently offline Christian BrandFriend
Messages: 36
Registered: July 2009
Location: Walldorf/Germany
Member
Did you check your implementation of org.eclipse.graphiti.tb.IToolBehaviorProvider.getContextMenu(ICustomContext)?

If your implementation is okay, please open a bugzilla? We will care for it.


Christian Brand
SAP AG - Walldorf - Germany

[Updated on: Fri, 24 August 2012 06:25]

Report message to a moderator

Re: Problem with Context Menu [message #903572 is a reply to message #903520] Fri, 24 August 2012 11:38 Go to previous messageGo to next message
Abie Ikhsan is currently offline Abie IkhsanFriend
Messages: 4
Registered: August 2012
Junior Member
I did check the implementation of org.eclipse.graphiti.tb.IToolBehaviorProvider.getContextMenu(ICustomContext) and I didn't see any problem so far. This is the bugzilla for the problem: https://bugs.eclipse.org/bugs/show_bug.cgi?id=387971
Re: Problem with Context Menu [message #903713 is a reply to message #903444] Fri, 24 August 2012 07:34 Go to previous messageGo to next message
Michael Wenz is currently offline Michael WenzFriend
Messages: 1931
Registered: July 2009
Location: Walldorf, Germany
Senior Member
Abie,

just an idea, not sure if it helps...

Do you have defined an editor as subclass of DiagramEditor? In case yes, did
you also set an action bar contributor? It should be a subclass of
DiagramEditorActionBarContributor. At least copy&paste involves the actions
registered with Eclipse.

Michael
Re: Problem with Context Menu [message #903931 is a reply to message #903713] Mon, 27 August 2012 11:01 Go to previous messageGo to next message
Abie Ikhsan is currently offline Abie IkhsanFriend
Messages: 4
Registered: August 2012
Junior Member
Thank you Michael for the suggestion. Yes we have a diagram editor class as subclass of DiagramEditor which is invoked from a MultiPageEditor. According to your suggestion, I've tried to implement a subclass of DiagramEditorActionBarContributor but I don't really know which method should be overrided or changed in order to make those features work. You can have a look at our editor implementation of the project from this following link: github.com/mrzon/GraphBT/tree/master/BehaviorTreeModel/src/behaviortree/editor
Re: Problem with Context Menu [message #904283 is a reply to message #903931] Tue, 28 August 2012 07:02 Go to previous messageGo to next message
Michael Wenz is currently offline Michael WenzFriend
Messages: 1931
Registered: July 2009
Location: Walldorf, Germany
Senior Member
Abie,

There' a small example of a multi page editor hosting a diagram editor in
one of out test tools. Have a look into
http://git.eclipse.org/c/gmp/org.eclipse.gmp.graphiti.git/tree/tests/org.eclipse.graphiti.testtool.sketch/src/org/eclipse/graphiti/testtool/sketch/editors/MultiPageEditorContributor.java

Michael
Re: Problem with Context Menu [message #904495 is a reply to message #904283] Tue, 28 August 2012 14:30 Go to previous message
Abie Ikhsan is currently offline Abie IkhsanFriend
Messages: 4
Registered: August 2012
Junior Member
Hi Michael,

Thanks for your input. Our implementation of MultiPageEditor is already based on that link. However, it seems that we were not correctly implement (something that we don't sure how implement it) the action bar contributor, so the context menu is still disabled when we "right click" any graphical object. For instance, we already implement a CopyFeature, we expect the method "canCopy" returns true as it was already specified. We are trying to search for the source of the problem, whether there are such things that should be registered, or some additional implementation of which that isn't covered on the tutorial as it is not using MultiPageEditor. You may check the git link we give to see our editor implementation.
https:// github.com/mrzon/GraphBT/tree/master4/BehaviorTreeModel/src/behaviortree/editor

Thanks.

[Updated on: Tue, 28 August 2012 14:33]

Report message to a moderator

Previous Topic:MoveContext
Next Topic:Property sheet
Goto Forum:
  


Current Time: Tue Apr 23 14:11:40 GMT 2024

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

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

Back to the top