Old GEF problem [message #1785817] |
Fri, 20 April 2018 05:36  |
Eclipse User |
|
|
|
Hi, im using GEF 3.9 and I encountered a problem, which im not sure whether is connected with the old version of GEF, or some bug in my code.
In palette of the editor in my application I have CombinedTemplateCreationEntry. I think, that after selecting this entry and clicking on the editor there should be CreateRequest genereated and sent to corresponding Part.
I have a Part implemented with installed XYLayoutPolicy. It does handle the request as intended. The problem is, CreateRequest is generated instantly after I hover over the Part with the entry selected from palette. I believe it should be generated only after the Part is clicked on.
I have also implemented the drag-and-drop functionality, and it works fine. But I'd like to be able to pick a tool from palette and then create some elements by clicking on the container Part of the editor. Right now, the request is handled instanlty after mouse enters the container Part.
Code fragments:
- installing Policy in NodeEditPart:
@Override
protected void createEditPolicies()
{
installEditPolicy(EditPolicy.LAYOUT_ROLE, new ChangeLayoutPolicy());
installEditPolicy(EditPolicy.NODE_ROLE, new RenamePolicy());
}
- Handling Request in Policy (called instantly after the hover):
@Override
protected Command getCreateCommand(CreateRequest request){
try{
if(request.getType() == REQ_CREATE && getHost() instanceof CrmWorkflowEditPart){
// preparing the command
-Creating the Entry fragment in getPaletteRoot():
PaletteDrawer stateElements = new PaletteDrawer("Stany");
root.add(stateElements);
ImageDescriptor workflowStateImage = ImagesUtil.getImageDescriptor(ImagesUtil.STATE);
PaletteNodeCreationFactory workflowStateFactory = new PaletteNodeCreationFactory(WorkflowState.class);
CombinedTemplateCreationEntry stateEntry = new CombinedTemplateCreationEntry("Workflow State", "Stan", WorkflowState.class,
workflowStateFactory, workflowStateImage, workflowStateImage);
stateElements.add(stateEntry);
stateEntry is the entry.
Thanks for Your time
|
|
|
|
Re: Old GEF problem [message #1785921 is a reply to message #1785911] |
Mon, 23 April 2018 03:32   |
Eclipse User |
|
|
|
Hi Alexander,
Thank you very much for the reply. I understand that now. However, I'd like to have one more question. In order to execute the command, I need to get some input from the user. If that was handled in the command, then canceling the prompt window would result in a "empty" command, which would be technically executed, and so present on the command stack and liable to undo/redo. The prompt window should appear only after the click, and If the user cancels it, I'd like the command to never be executed. How can I "dispose" of the command from inside of it, or intercept the command after the click, but before execution by the tool?
Again, thank You for Your time.
[Updated on: Mon, 23 April 2018 03:40] by Moderator
|
|
|
|
Re: Old GEF problem [message #1785940 is a reply to message #1785936] |
Mon, 23 April 2018 07:14   |
Eclipse User |
|
|
|
Avoiding collecting user input from within the command is what I did - however, right now im doing it inside the policy, and that causes the premature window appearing problem. I checked these methods and I have another question - does the tool, at the time handleButtonUp/Down is called, already have the command, the same that will be later executed, taken from the part? Then I'd need to fill it with user data and pass on. Or will the tool query for a command again, and I should instead update request and handle it in the policy (then policy would need to expect two "types" of requests - one without data, checking whether the creation is possible, and another with data).
Im sorry if I misunderstand something. Your responses have been very helpful so far.
|
|
|
|
|
Re: Old GEF problem [message #1786019 is a reply to message #1786017] |
Tue, 24 April 2018 04:33  |
Eclipse User |
|
|
|
I agree, it works, but it doesnt soud right. Hmm... I think overriding AbstractTool#executeCurrentCommand() would be perfect, but how can I do that, if im using CombinedTemplateCreationEntry/ConnectionCreationToolEntry? Is there a way to override Entry's method of executing command?
|
|
|
Powered by
FUDForum. Page generated in 0.03128 seconds