Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » GEF » Old GEF problem(Problem with CombinedTemplateCreationEntry in GEF 3.9)
Old GEF problem [message #1785817] Fri, 20 April 2018 09:36 Go to next message
Filip Raszka is currently offline Filip RaszkaFriend
Messages: 5
Registered: April 2018
Junior Member
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 #1785911 is a reply to message #1785817] Mon, 23 April 2018 05:31 Go to previous messageGo to next message
Alexander Nyssen is currently offline Alexander NyssenFriend
Messages: 235
Registered: July 2009
Location: Lünen
Senior Member
Hi Filip,

the request is created and issued to the part you are currently hovering in order to determine whether the create operation is allowed there. In case the part replies with a command that is executable, the cursor will be updated to indicate that the creation is possible. As this decision is taken by the part, the request has to be sent to it in order to obtain the command already when hovering. When being clicked, the command is then executed.

Please be aware that there is a difference in handling a request by returning a command (this is what the part or more precisely its policies are responsible for) and executing the command when the click occurs (which is done by the tool).

Regards,
Alexander
Re: Old GEF problem [message #1785921 is a reply to message #1785911] Mon, 23 April 2018 07:32 Go to previous messageGo to next message
Filip Raszka is currently offline Filip RaszkaFriend
Messages: 5
Registered: April 2018
Junior Member
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 07:40]

Report message to a moderator

Re: Old GEF problem [message #1785936 is a reply to message #1785921] Mon, 23 April 2018 10:30 Go to previous messageGo to next message
Alexander Nyssen is currently offline Alexander NyssenFriend
Messages: 235
Registered: July 2009
Location: Lünen
Senior Member
You should not collect the user input from within the command. Instead, you should intercept the creation process and populate the request. Take a look into the CreationTool#handleButtonDown() or #handleButtonUp().
Re: Old GEF problem [message #1785940 is a reply to message #1785936] Mon, 23 April 2018 11:14 Go to previous messageGo to next message
Filip Raszka is currently offline Filip RaszkaFriend
Messages: 5
Registered: April 2018
Junior Member
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 #1786016 is a reply to message #1785940] Tue, 24 April 2018 07:52 Go to previous messageGo to next message
Filip Raszka is currently offline Filip RaszkaFriend
Messages: 5
Registered: April 2018
Junior Member
I've come to a solution, but im not sure how correct is it. Im going to override CommandStack#execute, so that before execution it can collect user input. I hope it's not something that should be avoided.
Re: Old GEF problem [message #1786017 is a reply to message #1786016] Tue, 24 April 2018 07:58 Go to previous messageGo to next message
Alexander Nyssen is currently offline Alexander NyssenFriend
Messages: 235
Registered: July 2009
Location: Lünen
Senior Member
That doesn't sound right. As said, the tool would rather be the place to do this.
Re: Old GEF problem [message #1786019 is a reply to message #1786017] Tue, 24 April 2018 08:33 Go to previous message
Filip Raszka is currently offline Filip RaszkaFriend
Messages: 5
Registered: April 2018
Junior Member
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?
Previous Topic:[GEF5] Hover Feedback parts and zoom
Next Topic:Set Figure ClientArea
Goto Forum:
  


Current Time: Wed Nov 14 17:31:14 GMT 2018

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

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

Back to the top