question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Support enabling and disabling tools at runtime

See original GitHub issue

Especially when providing editing support, but also in other scenarios, it is useful to support enabling and disabling diagram tools, such as a node or edge creation tools, deletion tools, but also for non-editing scenarios, e.g. a special selection tool (for instance allowing to draw a rectangle with the mouse and every element that intersects will be selected). In traditional diagram editors, the enablement and disablement of tools is typically controlled by the user via a palette.

Currently, there is no dedicated infrastructure to control the enablement of tools in Sprotty. Tools are usually registered via DI, typically in the form of key and mouse listeners, and then remain active throughout the lifecycle of the diagram widget.

Therefore, we introduced a ToolManager in the graphical-lsp framework, which keeps a list of available tools and which manages their state. The tool manager itself is controlled via an action handler that reacts to dedicated actions (e.g. EnableToolsAction), so palette implementations can enable or disable tools by sending those actions. On each action enablement or disablement, the tool manager initializes or disposes the respective tools, which allows them to register and unregister their listeners, as well as to perform any arbitrary diagram modifications, etc., such as setting it up for visual feedback in the diagram, etc. that can later be cleaned up when the tool is disabled. To accommodate for the typical scenarios, the tool manager supports two types of tools, standard tools and “other” tools. Standard tools become active in the common user-interaction state until other tools are explicitly activated. Once a tool is finished or the user escapes the current interaction mode, all standard tools can be activated again.

We think this infrastructure might be interesting for Sprotty in general and not only for the graphical-lsp use case. If you agree, we’d be happy to open a PR. Please let us know what you think?

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:6 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
plangercommented, Nov 23, 2018

Thanks for your feedback!

I’ll then prepare a PR at latest beginning of Dec and we can continue the discussion on this PR then. I’m sure there might be some more additional capabilities needed in the manager to address all use cases. But I think this can more easily be sorted out in the PR.

Note: We currently have a lot of overlap, dependencies and ordering problems in the handling of events between the different “tool” usecases, resulting in some mix of responsibilities, e.g. the MoveMouseListener also manages editing of routing points, reconnecting edges and deletion of elements. Would be great if your approach addressed that such that we can compose behavior more clearly.

Right, that’s also what we have observed in our GLSP-specific listeners. Especially in those that are essentially supposed to only do something in specific use cases/modes. For us, another big advantage of the enablement and disablement of tools is that their statefulness is safer to manage (e.g. storing a previous selection when drawing an edge) and prepare/clean-up on enablement and disablement, e.g. for visual feedback or mouse decoration, etc…

I’m not sure that the tool manager solves the problem regarding the order of events though. However, it should allow us to separate concerns better and make the tools leaner as they can be more focused on a specific task.

Thanks again!

0reactions
spoenemanncommented, Feb 12, 2019

Yes.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Disabling and Enabling System Integrity Protection
Disable system protections only temporarily during development to test drivers, kernel extensions, and other low-level code.
Read more >
How to Disable/Enable a button tool in RunTime - Infragistics
Hi,. I want to have this button tool "btnOrders" disabled during runtime. private Infragistics.Win.UltraWinToolbars.
Read more >
Enable and disable Edit and Continue - Visual Studio (Windows)
Learn how to disable and enable Edit and Continue in Visual Studio Options at design time. Edit and Continue works only in debug...
Read more >
ArcMap Runtime Support: to Disable or Not to Disable? - Esri
When installing or upgrading ArcGIS Server, you'll be presented an option to disable the ArcMap Runtime Support feature. It will be enabled by ......
Read more >
Enabling or disabling a JBoss web connector at runtime in EAP
A Red Hat subscription provides unlimited access to our knowledgebase, tools, and much more. Current Customers and Partners. Log in for full ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found