This is an automated email from the ASF dual-hosted git repository.
lukaszlenart pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/struts-intellij-plugin.git
The following commit(s) were added to refs/heads/main by this push:
new 9394888 refactor: remove deprecated Graph editor tab (#94)
9394888 is described below
commit 9394888cd692adb1b1288033e580fbb4f7d460ea
Author: Lukasz Lenart <[email protected]>
AuthorDate: Thu Jun 25 15:43:30 2026 +0200
refactor: remove deprecated Graph editor tab (#94)
The legacy Graph tab used deprecated GraphBuilder APIs and has been
fully replaced by the Diagram tab. Remove the com.intellij.struts2.graph
package, its plugin.xml registration, and the enableGraphEditor JVM
property.
Co-authored-by: Cursor <[email protected]>
---
CHANGELOG.md | 4 +
README.md | 14 --
.../Struts2DiagramFileEditorProvider.java | 2 -
.../struts2/diagram/model/package-info.java | 8 +-
.../intellij/struts2/graph/StrutsDataModel.java | 208 ---------------------
.../intellij/struts2/graph/StrutsNodeRenderer.java | 45 -----
.../struts2/graph/StrutsPresentationModel.java | 168 -----------------
.../intellij/struts2/graph/beans/ActionNode.java | 41 ----
.../struts2/graph/beans/BasicStrutsEdge.java | 82 --------
.../struts2/graph/beans/BasicStrutsNode.java | 82 --------
.../intellij/struts2/graph/beans/ResultNode.java | 59 ------
.../graph/fileEditor/Struts2GraphComponent.java | 159 ----------------
.../graph/fileEditor/Struts2GraphFileEditor.java | 124 ------------
.../fileEditor/Struts2GraphFileEditorProvider.java | 105 -----------
.../com/intellij/struts2/graph/package-info.java | 19 --
src/main/resources/META-INF/plugin.xml | 1 -
16 files changed, 6 insertions(+), 1115 deletions(-)
diff --git a/CHANGELOG.md b/CHANGELOG.md
index f40aa83..44d3519 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -4,6 +4,10 @@
## [Unreleased]
+### Removed
+
+- Remove deprecated Graph editor tab (`com.intellij.struts2.graph`) and
`com.intellij.struts2.enableGraphEditor` JVM property; use the Diagram tab
instead
+
### Fixed
- Pin Marketplace ZIP Signer to `0.1.43` so `signPlugin` is deterministically
resolvable and no longer fails with "No Marketplace ZIP Signer executable
found" on a stale Gradle cache in the nightly/release workflows
diff --git a/README.md b/README.md
index f961cc4..5f418cc 100644
--- a/README.md
+++ b/README.md
@@ -28,20 +28,6 @@ Provides full integration of Apache Struts 2.
Questions related to the usage of the plugin should be posted to the [user
mailing list](https://struts.apache.org/mail.html).
Any issues should be reported using JIRA and [IDEA
plugin](https://issues.apache.org/jira/issues/?jql=project%20%3D%20WW%20AND%20component%20%3D%20%22IDEA%20Plugin%22)
component.
-## Optional features
-
-### Graph editor tab (disabled by default)
-
-The plugin includes a visual graph view for `struts.xml` configuration files.
This feature uses a deprecated IntelliJ Platform API and is disabled by default
because it can cause IDE freezes on newer platform versions.
-
-To enable it, add the following JVM property via **Help | Edit Custom VM
Options**:
-
-```
--Dcom.intellij.struts2.enableGraphEditor=true
-```
-
-Restart the IDE after adding the property. The `Graph` tab will then appear
when opening `struts.xml` files that are part of a Struts file set.
-
## Testing
Tests are located in `src/test/java` and use IntelliJ Platform test frameworks
(`LightJavaCodeInsightFixtureTestCase` and similar). Test data fixtures are in
`src/test/testData`.
diff --git
a/src/main/java/com/intellij/struts2/diagram/fileEditor/Struts2DiagramFileEditorProvider.java
b/src/main/java/com/intellij/struts2/diagram/fileEditor/Struts2DiagramFileEditorProvider.java
index 44bd789..7f887f3 100644
---
a/src/main/java/com/intellij/struts2/diagram/fileEditor/Struts2DiagramFileEditorProvider.java
+++
b/src/main/java/com/intellij/struts2/diagram/fileEditor/Struts2DiagramFileEditorProvider.java
@@ -34,8 +34,6 @@ import java.util.Set;
/**
* Provides the read-only "Diagram" tab for struts.xml files registered in a
Struts file set.
- * Uses the same eligibility rules as the legacy Graph tab but does not depend
on
- * deprecated {@code GraphBuilder} APIs.
*/
public class Struts2DiagramFileEditorProvider extends
PerspectiveFileEditorProvider {
diff --git a/src/main/java/com/intellij/struts2/diagram/model/package-info.java
b/src/main/java/com/intellij/struts2/diagram/model/package-info.java
index e3d3839..635f83c 100644
--- a/src/main/java/com/intellij/struts2/diagram/model/package-info.java
+++ b/src/main/java/com/intellij/struts2/diagram/model/package-info.java
@@ -21,12 +21,8 @@
* <h2>Migration boundary</h2>
* <p>The types in this package ({@link
com.intellij.struts2.diagram.model.StrutsConfigDiagramModel},
* {@link com.intellij.struts2.diagram.model.StrutsDiagramNode},
- * {@link com.intellij.struts2.diagram.model.StrutsDiagramEdge}) are
intentionally independent of both:</p>
- * <ul>
- * <li>The deprecated {@code com.intellij.openapi.graph.builder}
(GraphBuilder) APIs used by the legacy
- * {@code com.intellij.struts2.graph} package, and</li>
- * <li>The newer {@code com.intellij.diagram.Provider} (Diagrams API) that
may be adopted in the future.</li>
- * </ul>
+ * {@link com.intellij.struts2.diagram.model.StrutsDiagramEdge}) are
intentionally independent of
+ * the {@code com.intellij.diagram.Provider} (Diagrams API) that may be
adopted in the future.</p>
* <p>This isolation means that the rendering/editor layer (currently a
lightweight Swing panel in
* {@code com.intellij.struts2.diagram.ui}) can be replaced without touching
the DOM traversal or
* presentation logic. A future migration to {@code
com.intellij.diagram.Provider} should:</p>
diff --git a/src/main/java/com/intellij/struts2/graph/StrutsDataModel.java
b/src/main/java/com/intellij/struts2/graph/StrutsDataModel.java
deleted file mode 100644
index 86bdbb8..0000000
--- a/src/main/java/com/intellij/struts2/graph/StrutsDataModel.java
+++ /dev/null
@@ -1,208 +0,0 @@
-/*
- * Copyright 2010 The authors
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.intellij.struts2.graph;
-
-import com.intellij.openapi.graph.builder.GraphDataModel;
-import com.intellij.openapi.graph.builder.NodeGroupDescriptor;
-import com.intellij.openapi.graph.builder.NodesGroup;
-import com.intellij.openapi.graph.builder.components.BasicNodesGroup;
-import com.intellij.openapi.graph.view.NodeLabel;
-import com.intellij.openapi.graph.view.hierarchy.GroupNodeRealizer;
-import com.intellij.openapi.paths.PathReference;
-import com.intellij.openapi.project.Project;
-import com.intellij.psi.PsiFile;
-import com.intellij.psi.xml.XmlElement;
-import com.intellij.psi.xml.XmlFile;
-import com.intellij.struts2.dom.struts.action.Action;
-import com.intellij.struts2.dom.struts.action.Result;
-import com.intellij.struts2.dom.struts.model.StrutsManager;
-import com.intellij.struts2.dom.struts.model.StrutsModel;
-import com.intellij.struts2.dom.struts.strutspackage.StrutsPackage;
-import com.intellij.struts2.graph.beans.ActionNode;
-import com.intellij.struts2.graph.beans.BasicStrutsEdge;
-import com.intellij.struts2.graph.beans.BasicStrutsNode;
-import com.intellij.struts2.graph.beans.ResultNode;
-import org.jetbrains.annotations.NonNls;
-import org.jetbrains.annotations.NotNull;
-import org.jetbrains.annotations.Nullable;
-
-import java.util.*;
-
-/**
- * @author Yann Cébron
- * @author Sergey Vasiliev
- */
-public class StrutsDataModel extends GraphDataModel<BasicStrutsNode,
BasicStrutsEdge> {
-
- private final Set<BasicStrutsNode> myNodes = new HashSet<>();
- private final Set<BasicStrutsEdge> myEdges = new HashSet<>();
-
- private final Map<PsiFile, NodesGroup> myGroups = new HashMap<>();
-
- private final Project myProject;
- private final XmlFile myFile;
-
- @NonNls
- private static final String UNKNOWN = "???";
-
- public StrutsDataModel(final XmlFile file) {
- myFile = file;
- myProject = file.getProject();
- }
-
- @Override
- @NotNull
- public Collection<BasicStrutsNode> getNodes() {
- refreshDataModel();
- return myNodes;
- }
-
- @Override
- @NotNull
- public Collection<BasicStrutsEdge> getEdges() {
- return myEdges;
- }
-
- @Override
- @NotNull
- public BasicStrutsNode getSourceNode(final BasicStrutsEdge edge) {
- return edge.getSource();
- }
-
- @Override
- @NotNull
- public BasicStrutsNode getTargetNode(final BasicStrutsEdge edge) {
- return edge.getTarget();
- }
-
- @Override
- @NotNull
- public String getNodeName(final BasicStrutsNode node) {
- return node.getName();
- }
-
- @Override
- @NotNull
- public String getEdgeName(final BasicStrutsEdge edge) {
- return edge.getName();
- }
-
- @Override
- public BasicStrutsEdge createEdge(@NotNull final BasicStrutsNode from,
@NotNull final BasicStrutsNode to) {
- return null;
- }
-
- @Override
- public void dispose() {
- }
-
- private void refreshDataModel() {
- myNodes.clear();
- myEdges.clear();
- updateDataModel();
- }
-
- @Override
- public NodeGroupDescriptor getGroup(final BasicStrutsNode basicStrutsNode)
{
- if (isGroupElements()) {
- final XmlElement xmlElement =
basicStrutsNode.getIdentifyingElement().getXmlElement();
- assert xmlElement != null;
- return myGroups.get(xmlElement.getContainingFile());
- }
-
- return super.getGroup(basicStrutsNode);
- }
-
- private void addNode(final BasicStrutsNode node) {
- if (!node.getIdentifyingElement().isValid()) {
- return;
- }
-
- myNodes.add(node);
-
- if (isGroupElements()) {
- final XmlElement element =
node.getIdentifyingElement().getXmlElement();
- assert element != null;
- final PsiFile file = element.getContainingFile();
- if (file != null && !myGroups.containsKey(file)) {
- final String name = file.getName();
-
- final BasicNodesGroup group = new BasicNodesGroup(name) {
-
- @Override
- public @NotNull GroupNodeRealizer
createGroupNodeRealizer() {
- final GroupNodeRealizer groupNodeRealizer =
super.createGroupNodeRealizer();
- assert groupNodeRealizer != null;
-
- final NodeLabel nodeLabel =
groupNodeRealizer.getLabel();
- nodeLabel.setText(" " + getGroupName());
- nodeLabel.setModel(NodeLabel.INTERNAL);
- nodeLabel.setPosition(NodeLabel.TOP_RIGHT);
-
- return groupNodeRealizer;
- }
- };
-
- // collapse all other files
- group.setClosed(file != myFile);
-
- myGroups.put(file, group);
-
- }
- }
- }
-
- // TODO configurable?
- private boolean isGroupElements() {
- return true;
- }
-
- private void addEdge(final BasicStrutsEdge edge) {
- if (!edge.getSource().getIdentifyingElement().isValid() ||
- !edge.getTarget().getIdentifyingElement().isValid()) {
- return;
- }
-
- myEdges.add(edge);
- }
-
- private void updateDataModel() {
- final StrutsModel model =
StrutsManager.getInstance(myProject).getModelByFile(myFile);
- if (model == null) {
- return;
- }
-
- for (final StrutsPackage strutsPackage : model.getStrutsPackages()) {
- for (final Action action : strutsPackage.getActions()) {
- final ActionNode actionNode = new ActionNode(action,
action.getName().getStringValue());
- addNode(actionNode);
-
- for (final Result result : action.getResults()) {
- final PathReference pathReference = result.getValue();
- final String path = pathReference != null ?
pathReference.getPath() : UNKNOWN;
-
- final ResultNode resultNode = new ResultNode(result, path);
- addNode(resultNode);
-
- final String resultName =
result.getName().getStringValue();
- addEdge(new BasicStrutsEdge(actionNode, resultNode,
resultName != null ? resultName : Result.DEFAULT_NAME));
- }
-
- }
- }
-
- }
-
-}
\ No newline at end of file
diff --git a/src/main/java/com/intellij/struts2/graph/StrutsNodeRenderer.java
b/src/main/java/com/intellij/struts2/graph/StrutsNodeRenderer.java
deleted file mode 100644
index 83d61b2..0000000
--- a/src/main/java/com/intellij/struts2/graph/StrutsNodeRenderer.java
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * Copyright 2008 The authors
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.intellij.struts2.graph;
-
-import com.intellij.openapi.graph.builder.GraphBuilder;
-import com.intellij.openapi.graph.builder.renderer.BasicGraphNodeRenderer;
-import com.intellij.psi.PsiManager;
-import com.intellij.struts2.graph.beans.BasicStrutsEdge;
-import com.intellij.struts2.graph.beans.BasicStrutsNode;
-
-import javax.swing.*;
-
-/**
- * @author Yann Cébron
- * @author Sergey Vasiliev
- */
-public class StrutsNodeRenderer extends
BasicGraphNodeRenderer<BasicStrutsNode, BasicStrutsEdge> {
-
- public StrutsNodeRenderer(final GraphBuilder<BasicStrutsNode,
BasicStrutsEdge> graphBuilder) {
- super(graphBuilder,
PsiManager.getInstance(graphBuilder.getProject()).getModificationTracker());
- }
-
- @Override
- protected Icon getIcon(final BasicStrutsNode node) {
- return node.getIcon();
- }
-
- @Override
- protected String getNodeName(final BasicStrutsNode node) {
- return node.getName();
- }
-
-}
\ No newline at end of file
diff --git
a/src/main/java/com/intellij/struts2/graph/StrutsPresentationModel.java
b/src/main/java/com/intellij/struts2/graph/StrutsPresentationModel.java
deleted file mode 100644
index 64aac55..0000000
--- a/src/main/java/com/intellij/struts2/graph/StrutsPresentationModel.java
+++ /dev/null
@@ -1,168 +0,0 @@
-/*
- * Copyright 2019 The authors
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.intellij.struts2.graph;
-
-import
com.intellij.openapi.graph.builder.components.BasicGraphPresentationModel;
-import com.intellij.openapi.graph.builder.renderer.BasicGraphNodeRenderer;
-import com.intellij.openapi.graph.services.GraphNodeRealizerService;
-import com.intellij.openapi.graph.view.*;
-import com.intellij.openapi.paths.PathReference;
-import com.intellij.openapi.util.registry.Registry;
-import com.intellij.openapi.util.text.StringUtil;
-import com.intellij.pom.Navigatable;
-import com.intellij.psi.PsiClass;
-import com.intellij.psi.xml.XmlElement;
-import com.intellij.struts2.dom.struts.action.Action;
-import com.intellij.struts2.dom.struts.action.Result;
-import com.intellij.struts2.dom.struts.strutspackage.ResultType;
-import com.intellij.struts2.dom.struts.strutspackage.StrutsPackage;
-import com.intellij.struts2.graph.beans.BasicStrutsEdge;
-import com.intellij.struts2.graph.beans.BasicStrutsNode;
-import com.intellij.util.OpenSourceUtil;
-import com.intellij.util.xml.DomElement;
-import org.jetbrains.annotations.NonNls;
-import org.jetbrains.annotations.NotNull;
-import org.jetbrains.annotations.Nullable;
-
-/**
- * @author Yann Cébron
- * @author Sergey Vasiliev
- */
-public class StrutsPresentationModel extends
BasicGraphPresentationModel<BasicStrutsNode, BasicStrutsEdge> {
-
- private BasicGraphNodeRenderer myRenderer;
-
- public StrutsPresentationModel(final Graph2D graph) {
- super(graph);
- getSettings().setShowEdgeLabels(true);
- }
-
- @Override
- @NotNull
- public NodeRealizer getNodeRealizer(final @Nullable BasicStrutsNode node) {
- return
GraphNodeRealizerService.getInstance().createGenericNodeRealizer("Struts2NodeRenderer",
getRenderer());
- }
-
- private BasicGraphNodeRenderer getRenderer() {
- if (myRenderer == null) {
- myRenderer = new StrutsNodeRenderer(getGraphBuilder());
- }
- return myRenderer;
- }
-
- @Override
- public boolean editNode(final @Nullable BasicStrutsNode node) {
- if (node == null) { // TODO should not happen
- return false;
- }
-
- final XmlElement xmlElement = node.getIdentifyingElement().getXmlElement();
- if (xmlElement instanceof Navigatable) {
- OpenSourceUtil.navigate((Navigatable)xmlElement);
- return true;
- }
- return super.editNode(node);
- }
-
- @Override
- public boolean editEdge(final @Nullable BasicStrutsEdge edge) {
- if (edge == null) {
- return false; // TODO should not happen
- }
-
- final XmlElement xmlElement =
edge.getSource().getIdentifyingElement().getXmlElement();
- if (xmlElement instanceof Navigatable) {
- OpenSourceUtil.navigate((Navigatable)xmlElement);
- return true;
- }
- return super.editEdge(edge);
- }
-
- @Override
- public @Nullable String getNodeTooltip(@Nullable final BasicStrutsNode node)
{
- if (node == null) {
- return null;
- }
-
- final DomElement element = node.getIdentifyingElement();
- if (element instanceof Action action) {
- final StrutsPackage strutsPackage = action.getStrutsPackage();
-
- final DocumentationBuilder builder = new DocumentationBuilder();
- final PsiClass actionClass = action.searchActionClass();
- builder.addLine("Action", action.getName().getStringValue())
- .addLine("Class", actionClass != null ? actionClass.getQualifiedName()
: null)
- .addLine("Method", action.getMethod().getStringValue())
- .addLine("Package", strutsPackage.getName().getStringValue())
- .addLine("Namespace", strutsPackage.searchNamespace());
-
- return builder.getText();
- }
-
- if (element instanceof Result result) {
- final PathReference pathReference = result.getValue();
- final String displayPath = pathReference != null ?
pathReference.getPath() : "???";
- final ResultType resultType = result.getEffectiveResultType();
- final String resultTypeValue = resultType != null ?
resultType.getName().getStringValue() : "???";
-
- final DocumentationBuilder builder = new DocumentationBuilder();
- builder.addLine("Path", displayPath)
- .addLine("Type", resultTypeValue);
- return builder.getText();
- }
-
- return null;
- }
-
- @Override
- public void customizeSettings(final @NotNull Graph2DView view, final
@NotNull EditMode editMode) {
- editMode.allowBendCreation(false);
- editMode.allowEdgeCreation(false);
-
- view.setFitContentOnResize(false);
-
view.setAntialiasedPainting(Registry.is(BasicGraphPresentationModel.USE_ANTIALIAING_REGKEY));
- view.setGridVisible(false);
- view.fitContent();
- }
-
- /**
- * Builds HTML-table based descriptions for use in documentation, tooltips.
- *
- * @author Yann Cébron
- */
- private static class DocumentationBuilder {
-
- @NonNls
- private final StringBuilder builder = new StringBuilder("<html><table>");
-
- /**
- * Adds a labeled content line.
- *
- * @param label Content description.
- * @param content Content text, {@code null} or empty text will be
replaced with '-'.
- * @return this instance.
- */
- private DocumentationBuilder addLine(@NotNull @NonNls final String label,
@Nullable @NonNls final String content) {
-
builder.append("<tr><td><strong>").append(label).append(":</strong></td>")
- .append("<td>").append(StringUtil.isNotEmpty(content) ? content :
"-").append("</td></tr>");
- return this;
- }
-
- private String getText() {
- builder.append("</table></html>");
- return builder.toString();
- }
- }
-}
diff --git a/src/main/java/com/intellij/struts2/graph/beans/ActionNode.java
b/src/main/java/com/intellij/struts2/graph/beans/ActionNode.java
deleted file mode 100644
index 924f857..0000000
--- a/src/main/java/com/intellij/struts2/graph/beans/ActionNode.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * Copyright 2008 The authors
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.intellij.struts2.graph.beans;
-
-import com.intellij.struts2.Struts2Icons;
-import com.intellij.struts2.dom.struts.action.Action;
-import org.jetbrains.annotations.NotNull;
-import org.jetbrains.annotations.Nullable;
-
-import javax.swing.*;
-
-/**
- * Represents {@link Action} element.
- *
- * @author Yann Cébron
- */
-public class ActionNode extends BasicStrutsNode<Action> {
-
- public ActionNode(@NotNull final Action identifyingElement, @Nullable final
String name) {
- super(identifyingElement, name);
- }
-
- @Override
- @NotNull
- public Icon getIcon() {
- return Struts2Icons.Action;
- }
-
-}
diff --git
a/src/main/java/com/intellij/struts2/graph/beans/BasicStrutsEdge.java
b/src/main/java/com/intellij/struts2/graph/beans/BasicStrutsEdge.java
deleted file mode 100644
index 19c9a0a..0000000
--- a/src/main/java/com/intellij/struts2/graph/beans/BasicStrutsEdge.java
+++ /dev/null
@@ -1,82 +0,0 @@
-/*
- * Copyright 2008 The authors
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.intellij.struts2.graph.beans;
-
-import org.jetbrains.annotations.NonNls;
-import org.jetbrains.annotations.NotNull;
-
-/**
- * @author Yann Cébron
- */
-public class BasicStrutsEdge {
-
- private final BasicStrutsNode mySource;
- private final BasicStrutsNode myTarget;
-
- @NonNls
- @NotNull
- private final String name;
-
- public BasicStrutsEdge(@NotNull final BasicStrutsNode source,
- @NotNull final BasicStrutsNode target,
- @NotNull @NonNls final String name) {
- mySource = source;
- myTarget = target;
- this.name = name;
- }
-
- @NonNls
- @NotNull
- public String getName() {
- return name;
- }
-
- public BasicStrutsNode getSource() {
- return mySource;
- }
-
- public BasicStrutsNode getTarget() {
- return myTarget;
- }
-
- public boolean equals(final Object o) {
- if (this == o) {
- return true;
- }
- if (o == null || getClass() != o.getClass()) {
- return false;
- }
-
- final BasicStrutsEdge that = (BasicStrutsEdge) o;
-
- if (!mySource.equals(that.mySource)) {
- return false;
- }
-
- if (!myTarget.equals(that.myTarget)) {
- return false;
- }
-
- return true;
- }
-
- public int hashCode() {
- int result;
- result = mySource.hashCode();
- result = 31 * result + myTarget.hashCode();
- return result;
- }
-
-}
\ No newline at end of file
diff --git
a/src/main/java/com/intellij/struts2/graph/beans/BasicStrutsNode.java
b/src/main/java/com/intellij/struts2/graph/beans/BasicStrutsNode.java
deleted file mode 100644
index 576a36f..0000000
--- a/src/main/java/com/intellij/struts2/graph/beans/BasicStrutsNode.java
+++ /dev/null
@@ -1,82 +0,0 @@
-/*
- * Copyright 2008 The authors
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.intellij.struts2.graph.beans;
-
-import com.intellij.util.xml.DomElement;
-import org.jetbrains.annotations.NonNls;
-import org.jetbrains.annotations.NotNull;
-import org.jetbrains.annotations.Nullable;
-
-import javax.swing.*;
-
-/**
- * Base class for nodes.
- *
- * @author Yann Cébron
- * @author Sergey Vasiliev
- */
-public abstract class BasicStrutsNode<T extends DomElement> {
-
- private final T myIdentifyingElement;
-
- @NonNls
- private final @NotNull String myName;
-
- /**
- * CTOR.
- *
- * @param identifyingElement Underlying DOM-element.
- * @param name Display name.
- */
- protected BasicStrutsNode(@NotNull final T identifyingElement, @Nullable
@NonNls final String name) {
- myIdentifyingElement = identifyingElement;
- myName = name != null ? name : "";
- }
-
- @NonNls
- @NotNull
- public String getName() {
- return myName;
- }
-
- @NotNull
- public T getIdentifyingElement() {
- return myIdentifyingElement;
- }
-
- @NotNull
- public abstract Icon getIcon();
-
- public boolean equals(final Object o) {
- if (this == o) {
- return true;
- }
- if (o == null || getClass() != o.getClass()) {
- return false;
- }
-
- final BasicStrutsNode<?> pagesNode = (BasicStrutsNode<?>)o;
- return myIdentifyingElement.equals(pagesNode.myIdentifyingElement) &&
- myName.equals(pagesNode.myName);
- }
-
- public int hashCode() {
- int result;
- result = myIdentifyingElement.hashCode();
- result = 31 * result + myName.hashCode();
- return result;
- }
-
-}
\ No newline at end of file
diff --git a/src/main/java/com/intellij/struts2/graph/beans/ResultNode.java
b/src/main/java/com/intellij/struts2/graph/beans/ResultNode.java
deleted file mode 100644
index c13ab9d..0000000
--- a/src/main/java/com/intellij/struts2/graph/beans/ResultNode.java
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * Copyright 2008 The authors
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.intellij.struts2.graph.beans;
-
-import com.intellij.icons.AllIcons;
-import com.intellij.openapi.paths.PathReference;
-import com.intellij.struts2.dom.struts.action.Result;
-import org.jetbrains.annotations.NotNull;
-
-import javax.swing.*;
-
-/**
- * Represents {@link Result} element.
- *
- * @author Yann Cébron
- */
-public class ResultNode extends BasicStrutsNode<Result> {
-
- private static final Icon UNKNOWN_RESULT_ICON = AllIcons.FileTypes.Unknown;
-
- public ResultNode(@NotNull final Result identifyingElement,
- @NotNull final String path) {
- super(identifyingElement, path);
- }
-
- @Override
- @NotNull
- public Icon getIcon() {
- final Result result = getIdentifyingElement();
- if (!result.isValid()) {
- return UNKNOWN_RESULT_ICON;
- }
-
- final PathReference pathReference = result.getValue();
- if (pathReference == null) {
- return UNKNOWN_RESULT_ICON;
- }
-
- if (pathReference.resolve() == null) {
- return UNKNOWN_RESULT_ICON;
- }
-
- final Icon pathReferenceIcon = pathReference.getIcon();
- return pathReferenceIcon != null ? pathReferenceIcon :
UNKNOWN_RESULT_ICON;
- }
-
-}
\ No newline at end of file
diff --git
a/src/main/java/com/intellij/struts2/graph/fileEditor/Struts2GraphComponent.java
b/src/main/java/com/intellij/struts2/graph/fileEditor/Struts2GraphComponent.java
deleted file mode 100644
index fda4dc5..0000000
---
a/src/main/java/com/intellij/struts2/graph/fileEditor/Struts2GraphComponent.java
+++ /dev/null
@@ -1,159 +0,0 @@
-/*
- * Copyright 2011 The authors
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.intellij.struts2.graph.fileEditor;
-
-import com.intellij.openapi.Disposable;
-import com.intellij.openapi.actionSystem.*;
-import com.intellij.openapi.graph.GraphManager;
-import com.intellij.openapi.graph.builder.GraphBuilder;
-import com.intellij.openapi.graph.builder.GraphBuilderFactory;
-import com.intellij.openapi.graph.builder.actions.AbstractGraphAction;
-import com.intellij.openapi.graph.services.GraphSelectionService;
-import com.intellij.openapi.graph.view.Graph2D;
-import com.intellij.openapi.graph.view.Graph2DView;
-import com.intellij.openapi.graph.view.Overview;
-import com.intellij.openapi.progress.ProgressIndicator;
-import com.intellij.openapi.progress.ProgressManager;
-import com.intellij.openapi.project.Project;
-import com.intellij.openapi.util.Disposer;
-import com.intellij.psi.xml.XmlFile;
-import com.intellij.struts2.graph.StrutsDataModel;
-import com.intellij.struts2.graph.StrutsPresentationModel;
-import com.intellij.struts2.graph.beans.BasicStrutsEdge;
-import com.intellij.struts2.graph.beans.BasicStrutsNode;
-import com.intellij.util.containers.ContainerUtil;
-import com.intellij.util.xml.DomElement;
-import com.intellij.util.xml.DomEventListener;
-import com.intellij.util.xml.DomManager;
-import com.intellij.util.xml.events.DomEvent;
-import org.jetbrains.annotations.NotNull;
-
-import javax.swing.*;
-import java.awt.*;
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * @author Yann Cébron
- */
-public class Struts2GraphComponent extends JPanel implements UiDataProvider,
Disposable {
- static final DataKey<Struts2GraphComponent> DATA_KEY =
DataKey.create("STRUTS2_DESIGNER_COMPONENT");
-
- private final GraphBuilder<BasicStrutsNode, BasicStrutsEdge> myBuilder;
-
- @SuppressWarnings({"UnstableApiUsage", "deprecation"})
- // TODO: GraphBuilder.queueUpdate()/initialize() deprecated with no public
replacement.
- // Migrate to com.intellij.diagram.Provider extension point (Diagrams
API).
- // See:
https://platform.jetbrains.com/t/any-documentation-for-com-intellij-diagrams/320
- public Struts2GraphComponent(final XmlFile xmlFile) {
- final ProgressIndicator progress =
ProgressManager.getInstance().getProgressIndicator();
-
- progress.setText("Initializing...");
- final Project project = xmlFile.getProject();
- final Graph2D graph = GraphManager.getGraphManager().createGraph2D();
- final Graph2DView view =
GraphManager.getGraphManager().createGraph2DView();
-
- progress.setText("Building model...");
- final StrutsDataModel myDataModel = new StrutsDataModel(xmlFile);
- final StrutsPresentationModel presentationModel = new
StrutsPresentationModel(graph);
-
- progress.setText("Setup graph...");
- myBuilder =
GraphBuilderFactory.getInstance(project).createGraphBuilder(graph,
- view,
- myDataModel,
- presentationModel);
- Disposer.register(this, myBuilder);
-
- JComponent graphComponent = myBuilder.getView().getJComponent();
- setLayout(new BorderLayout());
-
- ActionToolbar toolbar =
ActionManager.getInstance().createActionToolbar(
- ActionPlaces.TOOLBAR,
AbstractGraphAction.getCommonToolbarActions(), true);
- toolbar.setTargetComponent(graphComponent);
-
- add(toolbar.getComponent(), BorderLayout.NORTH);
- add(graphComponent, BorderLayout.CENTER);
-
- // TODO: GraphBuilder.initialize() is @Internal API with no public
replacement.
- // Consider migrating to Diagram API when available.
- myBuilder.initialize();
-
-
DomManager.getDomManager(myBuilder.getProject()).addDomEventListener(new
DomEventListener() {
- @Override
- public void eventOccured(@NotNull final DomEvent event) {
- if (isShowing()) {
- // TODO: GraphBuilder.queueUpdate() is deprecated with no
public replacement.
- myBuilder.queueUpdate();
- }
- }
- }, this);
- }
-
- public List<DomElement> getSelectedDomElements() {
- final var selected = new ArrayList<DomElement>();
-
GraphSelectionService.getInstance().forEachSelectedNode(myBuilder.getGraph(),
node -> {
- final var nodeObject = myBuilder.getNodeObject(node);
- if (nodeObject != null) {
- ContainerUtil.addIfNotNull(selected,
nodeObject.getIdentifyingElement());
- }
- });
- return selected;
- }
-
- public void setSelectedDomElement(final DomElement domElement) {
- // TODO
- //if (domElement == null) return;
- //
- //final SeamPagesDomElement pageflowDomElement =
domElement.getParentOfType(SeamPagesDomElement.class, false);
- //if (pageflowDomElement == null) return;
- //
- //final Node selectedNode = myBuilder.getNode(pageflowDomElement);
- //
- //if (selectedNode != null) {
- // final Graph2D graph = myBuilder.getGraph();
- //
- // for (Node n : graph.getNodeArray()) {
- // final boolean selected = n.equals(selectedNode);
- // graph.setSelected(n, selected);
- // if (selected) {
- // final YRectangle yRectangle = graph.getRectangle(n);
- // if (!myBuilder.getView().getVisibleRect().contains(
- // new Rectangle((int)yRectangle.getX(),
(int)yRectangle.getY(), (int)yRectangle.getWidth(),
(int)yRectangle.getHeight()))) {
- // myBuilder.getView().setCenter(graph.getX(n), graph.getY(n));
- // }
- // }
- // }
- //}
- //myBuilder.getView().updateView();
- }
-
- public GraphBuilder getBuilder() {
- return myBuilder;
- }
-
- public Overview getOverview() {
- return
GraphManager.getGraphManager().createOverview(myBuilder.getView());
- }
-
- @Override
- public void dispose() {
- }
-
- @Override
- public void uiDataSnapshot(@NotNull DataSink sink) {
- sink.set(DATA_KEY, this);
- }
-
-}
\ No newline at end of file
diff --git
a/src/main/java/com/intellij/struts2/graph/fileEditor/Struts2GraphFileEditor.java
b/src/main/java/com/intellij/struts2/graph/fileEditor/Struts2GraphFileEditor.java
deleted file mode 100644
index 73d0163..0000000
---
a/src/main/java/com/intellij/struts2/graph/fileEditor/Struts2GraphFileEditor.java
+++ /dev/null
@@ -1,124 +0,0 @@
-/*
- * Copyright 2015 The authors
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.intellij.struts2.graph.fileEditor;
-
-import com.intellij.ide.structureView.StructureViewBuilder;
-import com.intellij.openapi.application.ReadAction;
-import
com.intellij.openapi.graph.builder.components.GraphStructureViewBuilderSetup;
-import com.intellij.openapi.progress.ProgressManager;
-import com.intellij.openapi.project.Project;
-import com.intellij.openapi.util.Disposer;
-import com.intellij.openapi.util.NotNullLazyValue;
-import com.intellij.openapi.vfs.VirtualFile;
-import com.intellij.psi.PsiFile;
-import com.intellij.psi.xml.XmlFile;
-import com.intellij.util.xml.DomElement;
-import com.intellij.util.xml.ui.PerspectiveFileEditor;
-import org.jetbrains.annotations.NotNull;
-import org.jetbrains.annotations.Nullable;
-
-import javax.swing.*;
-import java.util.List;
-
-/**
- * @author Yann Cébron
- */
-public class Struts2GraphFileEditor extends PerspectiveFileEditor {
-
- private Struts2GraphComponent myComponent;
- private final XmlFile myXmlFile;
-
- private final @NotNull NotNullLazyValue<StructureViewBuilder>
myStructureViewBuilder =
- NotNullLazyValue.atomicLazy(() ->
GraphStructureViewBuilderSetup.setupFor(getStruts2GraphComponent().getBuilder(),
null));
-
- public Struts2GraphFileEditor(final Project project, final VirtualFile
file) {
- super(project, file);
-
- final PsiFile psiFile = getPsiFile();
- assert psiFile instanceof XmlFile;
-
- myXmlFile = (XmlFile) psiFile;
- }
-
- @Override
- @Nullable
- protected DomElement getSelectedDomElement() {
- final List<DomElement> selectedDomElements =
getStruts2GraphComponent().getSelectedDomElements();
-
- return selectedDomElements.size() > 0 ? selectedDomElements.get(0) :
null;
- }
-
- @Override
- protected void setSelectedDomElement(final DomElement domElement) {
- getStruts2GraphComponent().setSelectedDomElement(domElement);
- }
-
- @Override
- @NotNull
- protected JComponent createCustomComponent() {
- return getStruts2GraphComponent();
- }
-
- @Override
- @Nullable
- public JComponent getPreferredFocusedComponent() {
- return
getStruts2GraphComponent().getBuilder().getView().getJComponent();
- }
-
- @Override
- public void commit() {
- }
-
- @Override
- @SuppressWarnings("deprecation") // TODO: GraphBuilder.queueUpdate() is
deprecated with no public replacement.
- public void reset() {
- getStruts2GraphComponent().getBuilder().queueUpdate();
- }
-
- @Override
- @NotNull
- public String getName() {
- return "Graph";
- }
-
- @Override
- public StructureViewBuilder getStructureViewBuilder() {
- return myStructureViewBuilder.getValue();
- }
-
- private Struts2GraphComponent getStruts2GraphComponent() {
- if (myComponent == null) {
- myComponent = createGraphComponent();
- Disposer.register(this, myComponent);
- }
- return myComponent;
- }
-
-
- /**
- * Creates graph component while showing modal wait dialog.
- *
- * @return new instance.
- */
- private Struts2GraphComponent createGraphComponent() {
- final Struts2GraphComponent[] graphComponent = {null};
- ProgressManager.getInstance().runProcessWithProgressSynchronously(
- (Runnable) () -> graphComponent[0] = ReadAction.nonBlocking(()
-> new Struts2GraphComponent(myXmlFile)).executeSynchronously(), "Generating
Graph", false, myXmlFile.getProject());
-
-
- return graphComponent[0];
- }
-}
\ No newline at end of file
diff --git
a/src/main/java/com/intellij/struts2/graph/fileEditor/Struts2GraphFileEditorProvider.java
b/src/main/java/com/intellij/struts2/graph/fileEditor/Struts2GraphFileEditorProvider.java
deleted file mode 100644
index cb68ac9..0000000
---
a/src/main/java/com/intellij/struts2/graph/fileEditor/Struts2GraphFileEditorProvider.java
+++ /dev/null
@@ -1,105 +0,0 @@
-/*
- * Copyright 2015 The authors
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.intellij.struts2.graph.fileEditor;
-
-import com.intellij.openapi.module.Module;
-import com.intellij.openapi.module.ModuleUtilCore;
-import com.intellij.openapi.project.Project;
-import com.intellij.openapi.vfs.VirtualFile;
-import com.intellij.psi.PsiFile;
-import com.intellij.psi.PsiManager;
-import com.intellij.psi.jsp.JspFile;
-import com.intellij.psi.xml.XmlFile;
-import com.intellij.struts2.dom.struts.model.StrutsManager;
-import com.intellij.struts2.facet.ui.StrutsFileSet;
-import com.intellij.util.xml.ui.PerspectiveFileEditor;
-import com.intellij.util.xml.ui.PerspectiveFileEditorProvider;
-import org.jetbrains.annotations.NotNull;
-
-import java.util.Set;
-
-/**
- * Provides "Graph"-tab for struts.xml files registered in S2 fileset.
- *
- * @author Yann Cébron
- */
-public class Struts2GraphFileEditorProvider extends
PerspectiveFileEditorProvider {
-
- /**
- * JVM system property to opt in to the (deprecated) Graph editor tab.
- * Disabled by default; enable with {@code
-Dcom.intellij.struts2.enableGraphEditor=true}.
- */
- static final String GRAPH_EDITOR_ENABLED_PROPERTY =
"com.intellij.struts2.enableGraphEditor";
-
- static boolean isGraphEditorEnabled() {
- return Boolean.getBoolean(GRAPH_EDITOR_ENABLED_PROPERTY);
- }
-
- @Override
- public boolean accept(@NotNull final Project project, @NotNull final
VirtualFile file) {
- if (!isGraphEditorEnabled()) {
- return false;
- }
-
- if (!file.isValid()) {
- return false;
- }
-
- final PsiFile psiFile = PsiManager.getInstance(project).findFile(file);
-
- if (!(psiFile instanceof XmlFile)) {
- return false;
- }
-
- if (psiFile instanceof JspFile) {
- return false;
- }
-
- if (!StrutsManager.getInstance(project).isStruts2ConfigFile((XmlFile)
psiFile)) {
- return false;
- }
-
- final Module module = ModuleUtilCore.findModuleForFile(file, project);
- if (module == null) {
- return false;
- }
-
- final Set<StrutsFileSet> fileSets =
StrutsManager.getInstance(project).getAllConfigFileSets(module);
- for (final StrutsFileSet fileSet : fileSets) {
- if (fileSet.hasFile(file)) {
- return true;
- }
- }
-
- return false;
- }
-
- @Override
- @NotNull
- public PerspectiveFileEditor createEditor(@NotNull final Project project,
@NotNull final VirtualFile file) {
- return new Struts2GraphFileEditor(project, file);
- }
-
- @Override
- public boolean isDumbAware() {
- return false;
- }
-
- @Override
- public double getWeight() {
- return 0;
- }
-
-}
diff --git a/src/main/java/com/intellij/struts2/graph/package-info.java
b/src/main/java/com/intellij/struts2/graph/package-info.java
deleted file mode 100644
index 67c95ee..0000000
--- a/src/main/java/com/intellij/struts2/graph/package-info.java
+++ /dev/null
@@ -1,19 +0,0 @@
-/*
- * Copyright 2008 The authors
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * Provides graph of struts.xml elements.
- */
-package com.intellij.struts2.graph;
\ No newline at end of file
diff --git a/src/main/resources/META-INF/plugin.xml
b/src/main/resources/META-INF/plugin.xml
index 8b86821..d20a9a9 100644
--- a/src/main/resources/META-INF/plugin.xml
+++ b/src/main/resources/META-INF/plugin.xml
@@ -168,7 +168,6 @@
<xmlStructureViewBuilderProvider
implementation="com.intellij.struts2.structure.StrutsStructureViewBuilderProvider"/>
- <fileEditorProvider
implementation="com.intellij.struts2.graph.fileEditor.Struts2GraphFileEditorProvider"/>
<fileEditorProvider
implementation="com.intellij.struts2.diagram.fileEditor.Struts2DiagramFileEditorProvider"/>
<struts2.resultContributor