-
Hello, I am working on the tasklist in the Java-EMF-Theia example. I am testing with the existing CreateNodeOperation and CreateTaskNodeHandler. I am currently trying to pass the name of the palette item that was clicked so that it can be sent as a string for data within the CreateNodeOperation operation and use it for the server. The reason for this I have set up for the palette to be loaded with palette items based on a custom source model provided by the user. I want an operation that will contain the certain palette item name so that I am able to use it. I have looked at the nonDraggingMouseUp function from the node-creation-tool.ts and see that this is where the operation is loaded so that it can be handled. Is there a way to acquire the name of the palette item that was selected so that the node that is placed will have the same name as the palette item. The reason for this is that they can be handled by the same handler; however, the difference is the name. |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments
-
I have continued looking and went to the tool-palette.ts file and have reached the OnClickCreateToolButton. I noticed the item has a label property that stores the palette item name. I would still like a guide on the best approach to pass this label to the server and what I will be creating. I mostly need help with binding. I am not experienced with the idea of binding or where to bind items since I assume I will have to bind my own palette that I extend from the original palette. If there is documentation on reading up more about binds, I would like to know about it. Thank you! |
Beta Was this translation helpful? Give feedback.
-
Hi @JValGLZ I think the correct way is to first implement a custom action command. And with this you can extend the Tool Palette with new Items and your corresponding Action. There should be no need to deal with Click Events on the client side. Take a look at our ToolPaletItemProvider in our own project. Maybe this helps you to get a better understanding. Such a Provider is than registered in your Diagram Module @Override
protected Class<? extends ToolPaletteItemProvider> bindToolPaletteItemProvider() {
return MyToolPaletteItemProvider.class;
} |
Beta Was this translation helpful? Give feedback.
-
Hi @JValGLZ, Assuming you are using the default public class MyToolPaletteItemProvider extends DefaultToolPaletteItemProvider {
@Override
protected PaletteItem create(final TriggerElementCreationAction action, final String label) {
// Add the label of the palette item as custom arg
action.getArgs().put("label", label);
return super.create(action, label);
}
} And configure the binding in your diagram module with @Override
protected Class<? extends ToolPaletteItemProvider> bindToolPaletteItemProvider() {
return MyToolPaletteItemProvider.class
} If you are already using a complete custom palette item provider you have to adjust the code accordingly, In your |
Beta Was this translation helpful? Give feedback.
Hi @JValGLZ,
as @rsoika already mentioned for your usecase you don't need to deal with click events on the client side.
The tool palette is populated from the server-side using
PaletteItems
. Each palette item is associated with aTriggerElementCreationAction
which will be dispatched when clicking the corresponding button. You can add arbitrary custom argumentsto this trigger action using the
args
property. This custom arguments can then be accessed in the correspondingCreateNodeOperation
.Assuming you are using the default
DefaultToolPaletteItemProvider
you could simply bind a customized version like this: