# This patch file was generated by NetBeans IDE # Following Index: paths are relative to: D:\ws\main # This patch can be applied using context Tools: Patch action on respective folder. # It uses platform neutral UTF-8 encoding and \n newlines. # Above lines and this line are ignored by the patching process. Index: maven.graph/nbproject/project.xml --- maven.graph/nbproject/project.xml +++ maven.graph/nbproject/project.xml @@ -121,6 +121,15 @@ + org.netbeans.modules.projectuiapi + + + + 1 + 1.71 + + + org.netbeans.modules.xml.xam Index: maven.graph/src/org/netbeans/modules/maven/graph/ArtifactWidget.java --- maven.graph/src/org/netbeans/modules/maven/graph/ArtifactWidget.java +++ maven.graph/src/org/netbeans/modules/maven/graph/ArtifactWidget.java @@ -50,6 +50,7 @@ import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.util.List; +import javax.swing.Icon; import javax.swing.Timer; import javax.swing.UIManager; import org.apache.maven.artifact.Artifact; @@ -109,7 +110,8 @@ private Timer hoverTimer; private Color hoverBorderC; - private LabelWidget artifactW, versionW; + private Widget artifactW; + private LabelWidget versionW; private Widget contentW; private ImageWidget lockW, fixHintW; @@ -120,7 +122,7 @@ private String tooltipText; - ArtifactWidget(DependencyGraphScene scene, ArtifactGraphNode node) { + ArtifactWidget(DependencyGraphScene scene, ArtifactGraphNode node, Icon icon) { super(scene); this.node = node; @@ -128,7 +130,7 @@ setLayout(LayoutFactory.createVerticalFlowLayout()); updateTooltip(); - initContent(scene, artifact); + initContent(scene, artifact, icon); hoverTimer = new Timer(500, this); hoverTimer.setRepeats(false); @@ -273,12 +275,21 @@ } @Messages("ACT_FixVersionConflict=Fix Version Conflict...") - private void initContent (DependencyGraphScene scene, Artifact artifact) { + private void initContent (DependencyGraphScene scene, Artifact artifact, Icon icon) { contentW = new LevelOfDetailsWidget(scene, 0.05, 0.1, Double.MAX_VALUE, Double.MAX_VALUE); contentW.setBorder(BorderFactory.createLineBorder(10)); contentW.setLayout(LayoutFactory.createVerticalFlowLayout(LayoutFactory.SerialAlignment.JUSTIFY, 1)); - artifactW = new LabelWidget(scene); - artifactW.setLabel(artifact.getArtifactId() + " "); + + //Artifact name (with optional project icon on the left) + artifactW = new Widget(scene); + artifactW.setLayout(LayoutFactory.createHorizontalFlowLayout(LayoutFactory.SerialAlignment.CENTER, 4)); + if (null != icon) { + artifactW.addChild(new ImageWidget(scene, ImageUtilities.icon2Image(icon))); + } + final LabelWidget labelWidget = new LabelWidget(scene, artifact.getArtifactId() + " "); + labelWidget.setUseGlyphVector(true); + artifactW.addChild(labelWidget); + if (node.isRoot()) { Font defF = scene.getDefaultFont(); artifactW.setFont(defF.deriveFont(Font.BOLD, defF.getSize() + 3f)); Index: maven.graph/src/org/netbeans/modules/maven/graph/DependencyGraphScene.java --- maven.graph/src/org/netbeans/modules/maven/graph/DependencyGraphScene.java +++ maven.graph/src/org/netbeans/modules/maven/graph/DependencyGraphScene.java @@ -48,11 +48,14 @@ import java.io.IOException; import java.util.ArrayList; import java.util.Collection; +import java.util.HashMap; import java.util.HashSet; import java.util.List; +import java.util.Map; import java.util.Set; import javax.swing.AbstractAction; import javax.swing.Action; +import javax.swing.Icon; import javax.swing.JPopupMenu; import javax.swing.JScrollPane; import javax.swing.JSeparator; @@ -63,6 +66,8 @@ import org.apache.maven.shared.dependency.tree.DependencyNode; import org.netbeans.api.annotations.common.CheckForNull; import org.netbeans.api.project.Project; +import org.netbeans.api.project.ProjectUtils; +import org.netbeans.api.project.ui.OpenProjects; import org.netbeans.api.visual.action.ActionFactory; import org.netbeans.api.visual.action.EditProvider; import org.netbeans.api.visual.action.MoveProvider; @@ -126,6 +131,7 @@ private static Set EMPTY_SELECTION = new HashSet(); private POMModel model; + private final Map projectIcons; /** Creates a new instance ofla DependencyGraphScene */ DependencyGraphScene(MavenProject prj, Project nbProj, DependencyGraphTopComponent tc, @@ -145,6 +151,7 @@ getActions().addAction(panAction); getActions().addAction(editAction); getActions().addAction(popupMenuAction); + this.projectIcons = getIconsForOpenProjects(); } @@ -183,6 +190,26 @@ } return null; } + /** + * @return map of maven artifact mapped to project icon + */ + Map getIconsForOpenProjects() { + Map result = new HashMap(); + //NOTE: surely not the best way to get the project icon + Project[] openProjects = OpenProjects.getDefault().getOpenProjects(); + for (Project project : openProjects) { + NbMavenProject mavenProject = project.getLookup().lookup(NbMavenProject.class); + if (null != mavenProject) { + Artifact artifact = mavenProject.getMavenProject().getArtifact(); + //get icon from opened project + Icon icon = ProjectUtils.getInformation(project).getIcon(); + if (null != icon) { + result.put(artifact, icon); + } + } + } + return result; + } @Override protected Widget attachNodeWidget(ArtifactGraphNode node) { if (rootNode == null) { @@ -191,7 +218,9 @@ if (node.getPrimaryLevel() > maxDepth) { maxDepth = node.getPrimaryLevel(); } - ArtifactWidget root = new ArtifactWidget(this, node); + Artifact artifact = node.getArtifact().getArtifact(); + Icon icon = projectIcons.get(artifact); + ArtifactWidget root = new ArtifactWidget(this, node, icon); mainLayer.addChild(root); node.setWidget(root); root.setOpaque(true);