Problem with Context Menu [message #903444] |
Thu, 23 August 2012 16:34 |
Abie Ikhsan 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 #904495 is a reply to message #904283] |
Tue, 28 August 2012 14:30 |
Abie Ikhsan 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
|
|
|
Powered by
FUDForum. Page generated in 0.03695 seconds