feat: add read-only Diagram tab for struts.xml config visualization#65
Open
lukaszlenart wants to merge 7 commits intomainfrom
Open
feat: add read-only Diagram tab for struts.xml config visualization#65lukaszlenart wants to merge 7 commits intomainfrom
lukaszlenart wants to merge 7 commits intomainfrom
Conversation
|
🔌 Plugin artifact ready for testing! Download from Actions artifacts Artifact: |
Introduce a lightweight Swing-based Diagram tab alongside the existing (disabled-by-default) Graph tab. The new tab renders packages, actions, and results in a hierarchical layout with tooltips and click-to-navigate, without depending on the deprecated GraphBuilder APIs. New components: - diagram/model: toolkit-neutral DTOs (node, edge, snapshot builder) - diagram/presentation: reusable tooltip/navigation helpers - diagram/ui: custom Swing renderer with hover and double-click support - diagram/fileEditor: PerspectiveFileEditorProvider + editor registration Made-with: Cursor
Add focused tests for Struts2DiagramFileEditorProvider verifying it accepts struts.xml in file sets and rejects plain XML, JSP, and Java files. Document the toolkit-neutral model layer as the migration boundary between the current Swing renderer and a future Diagrams API. Made-with: Cursor
Precompute tooltip HTML and navigation pointers during model snapshot creation (under read action) so Swing event handlers on the EDT never access DOM/PSI directly. Changes: - StrutsDiagramNode: replace DomElement with precomputed tooltipHtml and SmartPsiElementPointer for navigation - StrutsConfigDiagramModel.build(): compute tooltips and create smart pointers during snapshot (must be called under read action) - StrutsDiagramPresentation: split into computeTooltipHtml (build-time) and navigateToElement (EDT-safe via ReadAction.nonBlocking) - Struts2DiagramFileEditor: wrap build() in ReadAction.nonBlocking with progress dialog for initial load - Struts2DiagramComponent: use precomputed node.getTooltipHtml() instead of calling into DOM on hover Made-with: Cursor
Diagram model now resolves packages from the file-local StrutsRoot DOM instead of the merged StrutsModel, so only the current struts.xml's packages/actions/results are displayed. DTD validation is extracted into a shared StrutsDtdValidator helper and wired into Struts2ModelInspection.checkFileElement() as a file-level warning, so users see http:// vs https:// issues while editing rather than only when opening the Diagram tab. The Diagram-specific notification is removed since the inspection now covers it earlier. - Add StrutsDtdValidator shared helper for DTD URI checks - Add DTD check to Struts2ModelInspection with WARNING severity - Remove Diagram-side DTD notification (replaced by inspection) - Handle null model in Struts2DiagramFileEditor.reset() - Add StrutsConfigDiagramModelTest for local-file filtering - Add StrutsDtdValidatorTest for DTD validation logic - Add highlighting test for valid https:// DTD Made-with: Cursor
Replace ReadAction.nonBlocking().executeSynchronously() with Application.runReadAction(Computable) in navigateToElement() so double-clicking a Diagram node no longer throws an EDT assertion. The NBRA path asserts background-thread usage, but the mouse handler always runs on the EDT. The regular runReadAction is appropriate here since the work is just a SmartPsiElementPointer dereference. Adds a regression test verifying pointer resolution through the same Application.runReadAction path. Made-with: Cursor
Unify the editor rebuild path so initial load and reset() always reflect the current model state instead of retaining stale content. Add LOADED/EMPTY/UNAVAILABLE states to the diagram component with centered placeholder messages for non-loaded states. Replace raw ??? placeholders with descriptive labels ((unresolved path), (unnamed), (unknown type)). Extend tests to cover empty files, null models, rebuild transitions, and label clarity. Made-with: Cursor
24f171c to
211efe2
Compare
Replace display-based equals/hashCode (kind+name) in StrutsDiagramNode with a stable ID derived from the backing XML element's text offset. This prevents node collisions when duplicate action names or result paths exist across packages. Add focused tests for duplicate-name regression, edge topology and labels, editor lifecycle (creation and reset), and DTD validator classification outcomes. Made-with: Cursor
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Add a new lightweight Diagram tab for
struts.xmlfiles that replaces the deprecatedGraphBuilder-based editor with a custom Swing renderer. The tab visualizes packages, actions, and results from the current file only in a hierarchical three-column layout, with hover tooltips and double-click navigation.Key changes
-Dcom.intellij.struts2.enableGraphEditor=trueto avoid IDE freezes from deprecatedGraphBuilderAPIsdiagram/model), presentation helpers (diagram/presentation), custom Swing renderer (diagram/ui), and file editor provider (diagram/fileEditor)StrutsRootDOM, not the merged model, so only the currentstruts.xml's elements are shownApplication.runReadAction(Computable)instead of the EDT-forbiddenReadAction.nonBlocking().executeSynchronously()StrutsDtdValidatordetectshttp://vshttps://DTD URI mismatches and surfaces them as file-level warnings inStruts2ModelInspectionLOADED/EMPTY/UNAVAILABLEstate and renders centered placeholder messages instead of silent blank panels or stale content(unresolved path)instead of raw???; unnamed elements show(unnamed); tooltips use(unresolved)/(unknown type)New components
diagram/modelStrutsDiagramNode,StrutsDiagramEdge,StrutsConfigDiagramModel(snapshot builder)diagram/presentationdiagram/uidiagram/fileEditorPerspectiveFileEditorProvider+PerspectiveFileEditorregistered inplugin.xmldom/inspectionStrutsDtdValidatorshared DTD URI validation helperCommits
feat: disable deprecated Graph editor tab by default— gate old Graph tab behind JVM flagfeat: add read-only Diagram tab for struts.xml config visualization— initial Diagram implementationtest: add Diagram file editor provider tests and migration boundary docs— provider tests + architecture docsfix: resolve threading violations in Diagram tab— precompute tooltips/pointers under read actionfeat(diagram): show local packages only and add early DTD validation— file-local scoping + DTD inspectionfix(diagram): use EDT-safe read action for node navigation— fix double-click EDT assertionfeat(diagram): harden MVP with explicit states and clearer fallbacks— empty/error states, label polish, focused testsTest plan
struts.xmlfile in a project with a configured Struts file set./gradlew test -x ratpasses (all diagram + full suite)