8290063: IGV: Give the graphs a unique number in the outline
Reviewed-by: thartmann, chagedorn
This commit is contained in:
parent
b807470af4
commit
a1c349f8b3
@ -29,12 +29,11 @@ import com.sun.hotspot.igv.util.PropertiesSheet;
|
|||||||
import com.sun.hotspot.igv.util.StringUtils;
|
import com.sun.hotspot.igv.util.StringUtils;
|
||||||
import java.awt.Image;
|
import java.awt.Image;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import org.openide.nodes.AbstractNode;
|
import javax.swing.Action;
|
||||||
import org.openide.nodes.Children;
|
import org.openide.actions.PropertiesAction;
|
||||||
import org.openide.nodes.Node;
|
import org.openide.actions.RenameAction;
|
||||||
import org.openide.nodes.Sheet;
|
import org.openide.nodes.*;
|
||||||
import org.openide.util.ImageUtilities;
|
import org.openide.util.ImageUtilities;
|
||||||
import org.openide.util.lookup.AbstractLookup;
|
import org.openide.util.lookup.AbstractLookup;
|
||||||
import org.openide.util.lookup.InstanceContent;
|
import org.openide.util.lookup.InstanceContent;
|
||||||
@ -49,7 +48,7 @@ public class FolderNode extends AbstractNode {
|
|||||||
private final FolderChildren children;
|
private final FolderChildren children;
|
||||||
// NetBeans node corresponding to each opened graph. Used to highlight the
|
// NetBeans node corresponding to each opened graph. Used to highlight the
|
||||||
// focused graph in the Outline window.
|
// focused graph in the Outline window.
|
||||||
private static final Map<InputGraph, GraphNode> graphNode = new HashMap<>();
|
private static final Map<InputGraph, GraphNode> graphNodeMap = new HashMap<>();
|
||||||
private boolean selected = false;
|
private boolean selected = false;
|
||||||
|
|
||||||
private static class FolderChildren extends Children.Keys<FolderElement> implements ChangedListener {
|
private static class FolderChildren extends Children.Keys<FolderElement> implements ChangedListener {
|
||||||
@ -66,14 +65,14 @@ public class FolderNode extends AbstractNode {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Node[] createNodes(FolderElement e) {
|
protected Node[] createNodes(FolderElement folderElement) {
|
||||||
if (e instanceof InputGraph) {
|
if (folderElement instanceof InputGraph) {
|
||||||
InputGraph g = (InputGraph) e;
|
InputGraph inputGraph = (InputGraph) folderElement;
|
||||||
GraphNode n = new GraphNode(g);
|
GraphNode graphNode = new GraphNode(inputGraph);
|
||||||
graphNode.put(g, n);
|
graphNodeMap.put(inputGraph, graphNode);
|
||||||
return new Node[]{n};
|
return new Node[]{graphNode};
|
||||||
} else if (e instanceof Folder) {
|
} else if (folderElement instanceof Group) {
|
||||||
return new Node[]{new FolderNode((Folder) e)};
|
return new Node[]{new FolderNode((Group) folderElement)};
|
||||||
} else {
|
} else {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@ -83,19 +82,23 @@ public class FolderNode extends AbstractNode {
|
|||||||
protected void destroyNodes(Node[] nodes) {
|
protected void destroyNodes(Node[] nodes) {
|
||||||
for (Node n : nodes) {
|
for (Node n : nodes) {
|
||||||
// Each node is only present once in the graphNode map.
|
// Each node is only present once in the graphNode map.
|
||||||
graphNode.values().remove(n);
|
graphNodeMap.values().remove(n);
|
||||||
|
}
|
||||||
|
for (Node node : getNodes()) {
|
||||||
|
node.setDisplayName(node.getDisplayName());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void addNotify() {
|
public void addNotify() {
|
||||||
this.setKeys(folder.getElements());
|
super.addNotify();
|
||||||
|
setKeys(folder.getElements());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void changed(Object source) {
|
public void changed(Object source) {
|
||||||
addNotify();
|
addNotify();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -128,7 +131,7 @@ public class FolderNode extends AbstractNode {
|
|||||||
if (folder instanceof FolderElement) {
|
if (folder instanceof FolderElement) {
|
||||||
final FolderElement folderElement = (FolderElement) folder;
|
final FolderElement folderElement = (FolderElement) folder;
|
||||||
this.setDisplayName(folderElement.getName());
|
this.setDisplayName(folderElement.getName());
|
||||||
content.add((RemoveCookie) () -> {
|
this.content.add((RemoveCookie) () -> {
|
||||||
children.destroyNodes(children.getNodes());
|
children.destroyNodes(children.getNodes());
|
||||||
folderElement.getParent().removeElement(folderElement);
|
folderElement.getParent().removeElement(folderElement);
|
||||||
});
|
});
|
||||||
@ -141,6 +144,28 @@ public class FolderNode extends AbstractNode {
|
|||||||
fireIconChange();
|
fireIconChange();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean canRename() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setName(String name) {
|
||||||
|
children.getFolder().setName(name);
|
||||||
|
fireDisplayNameChange(null, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getName() {
|
||||||
|
return children.getFolder().getName();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getDisplayName() {
|
||||||
|
return children.getFolder().getDisplayName();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public String getHtmlDisplayName() {
|
public String getHtmlDisplayName() {
|
||||||
String htmlDisplayName = StringUtils.escapeHTML(getDisplayName());
|
String htmlDisplayName = StringUtils.escapeHTML(getDisplayName());
|
||||||
if (selected) {
|
if (selected) {
|
||||||
@ -149,15 +174,6 @@ public class FolderNode extends AbstractNode {
|
|||||||
return htmlDisplayName;
|
return htmlDisplayName;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void init(String name, List<Group> groups) {
|
|
||||||
this.setDisplayName(name);
|
|
||||||
children.addNotify();
|
|
||||||
|
|
||||||
for (Group g : groups) {
|
|
||||||
content.add(g);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isRootNode() {
|
public boolean isRootNode() {
|
||||||
Folder folder = getFolder();
|
Folder folder = getFolder();
|
||||||
return (folder instanceof GraphDocument);
|
return (folder instanceof GraphDocument);
|
||||||
@ -168,12 +184,20 @@ public class FolderNode extends AbstractNode {
|
|||||||
return getIcon(i);
|
return getIcon(i);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Action[] getActions(boolean b) {
|
||||||
|
return new Action[]{
|
||||||
|
RenameAction.findObject(RenameAction.class, true),
|
||||||
|
PropertiesAction.findObject(PropertiesAction.class, true),
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
public static void clearGraphNodeMap() {
|
public static void clearGraphNodeMap() {
|
||||||
graphNode.clear();
|
graphNodeMap.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static GraphNode getGraphNode(InputGraph graph) {
|
public static GraphNode getGraphNode(InputGraph graph) {
|
||||||
return graphNode.get(graph);
|
return graphNodeMap.get(graph);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Folder getFolder() {
|
public Folder getFolder() {
|
||||||
|
@ -32,6 +32,7 @@ import com.sun.hotspot.igv.util.StringUtils;
|
|||||||
import java.awt.Image;
|
import java.awt.Image;
|
||||||
import javax.swing.Action;
|
import javax.swing.Action;
|
||||||
import org.openide.actions.OpenAction;
|
import org.openide.actions.OpenAction;
|
||||||
|
import org.openide.actions.RenameAction;
|
||||||
import org.openide.nodes.*;
|
import org.openide.nodes.*;
|
||||||
import org.openide.util.ImageUtilities;
|
import org.openide.util.ImageUtilities;
|
||||||
import org.openide.util.Lookup;
|
import org.openide.util.Lookup;
|
||||||
@ -44,7 +45,7 @@ import org.openide.util.lookup.InstanceContent;
|
|||||||
*/
|
*/
|
||||||
public class GraphNode extends AbstractNode {
|
public class GraphNode extends AbstractNode {
|
||||||
|
|
||||||
private InputGraph graph;
|
private final InputGraph graph;
|
||||||
private boolean selected = false;
|
private boolean selected = false;
|
||||||
|
|
||||||
/** Creates a new instance of GraphNode */
|
/** Creates a new instance of GraphNode */
|
||||||
@ -52,12 +53,29 @@ public class GraphNode extends AbstractNode {
|
|||||||
this(graph, new InstanceContent());
|
this(graph, new InstanceContent());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean canRename() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setName(String name) {
|
||||||
|
graph.setName(name);
|
||||||
|
fireDisplayNameChange(null, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getName() {
|
||||||
|
return graph.getName();
|
||||||
|
}
|
||||||
|
|
||||||
public void setSelected(boolean selected) {
|
public void setSelected(boolean selected) {
|
||||||
this.selected = selected;
|
this.selected = selected;
|
||||||
fireDisplayNameChange(null, null);
|
fireDisplayNameChange(null, null);
|
||||||
fireIconChange();
|
fireIconChange();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public String getHtmlDisplayName() {
|
public String getHtmlDisplayName() {
|
||||||
String htmlDisplayName = StringUtils.escapeHTML(getDisplayName());
|
String htmlDisplayName = StringUtils.escapeHTML(getDisplayName());
|
||||||
if (selected) {
|
if (selected) {
|
||||||
@ -65,6 +83,12 @@ public class GraphNode extends AbstractNode {
|
|||||||
}
|
}
|
||||||
return htmlDisplayName;
|
return htmlDisplayName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getDisplayName() {
|
||||||
|
return graph.getDisplayName();
|
||||||
|
}
|
||||||
|
|
||||||
private GraphNode(InputGraph graph, InstanceContent content) {
|
private GraphNode(InputGraph graph, InstanceContent content) {
|
||||||
super(Children.LEAF, new AbstractLookup(content));
|
super(Children.LEAF, new AbstractLookup(content));
|
||||||
this.graph = graph;
|
this.graph = graph;
|
||||||
@ -86,13 +110,6 @@ public class GraphNode extends AbstractNode {
|
|||||||
|
|
||||||
// Action for cloning to the current graph
|
// Action for cloning to the current graph
|
||||||
content.add(new GraphCloneCookie(viewer, graph));
|
content.add(new GraphCloneCookie(viewer, graph));
|
||||||
|
|
||||||
this.addNodeListener(new NodeAdapter() {
|
|
||||||
@Override
|
|
||||||
public void childrenRemoved(NodeMemberEvent ev) {
|
|
||||||
GraphNode.this.graph = null;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -122,7 +139,12 @@ public class GraphNode extends AbstractNode {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Action[] getActions(boolean b) {
|
public Action[] getActions(boolean b) {
|
||||||
return new Action[]{DiffGraphAction.findObject(DiffGraphAction.class, true), CloneGraphAction.findObject(CloneGraphAction.class, true), OpenAction.findObject(OpenAction.class, true)};
|
return new Action[]{
|
||||||
|
RenameAction.findObject(RenameAction.class, true),
|
||||||
|
DiffGraphAction.findObject(DiffGraphAction.class, true),
|
||||||
|
CloneGraphAction.findObject(CloneGraphAction.class, true),
|
||||||
|
OpenAction.findObject(OpenAction.class, true)
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -20,6 +20,9 @@
|
|||||||
<file name="DS-W.shadow">
|
<file name="DS-W.shadow">
|
||||||
<attr name="originalFile" stringvalue="Actions/File/com-sun-hotspot-igv-coordinator-actions-RemoveAllAction.instance"/>
|
<attr name="originalFile" stringvalue="Actions/File/com-sun-hotspot-igv-coordinator-actions-RemoveAllAction.instance"/>
|
||||||
</file>
|
</file>
|
||||||
|
<file name="AD-R.shadow">
|
||||||
|
<attr name="originalFile" stringvalue="Actions/System/org-openide-actions-RenameAction.instance"/>
|
||||||
|
</file>
|
||||||
</folder>
|
</folder>
|
||||||
<folder name="Actions">
|
<folder name="Actions">
|
||||||
<folder name="File">
|
<folder name="File">
|
||||||
@ -58,27 +61,35 @@
|
|||||||
</file>
|
</file>
|
||||||
<file name="SeparatorSave.instance">
|
<file name="SeparatorSave.instance">
|
||||||
<attr name="instanceClass" stringvalue="javax.swing.JSeparator"/>
|
<attr name="instanceClass" stringvalue="javax.swing.JSeparator"/>
|
||||||
<attr name="position" intvalue="150"/>
|
<attr name="position" intvalue="200"/>
|
||||||
|
</file>
|
||||||
|
<file name="org-openide-actions-RenameAction.shadow">
|
||||||
|
<attr name="originalFile" stringvalue="Actions/System/org-openide-actions-RenameAction.instance"/>
|
||||||
|
<attr name="position" intvalue="300"/>
|
||||||
|
</file>
|
||||||
|
<file name="SeparatorRename.instance">
|
||||||
|
<attr name="instanceClass" stringvalue="javax.swing.JSeparator"/>
|
||||||
|
<attr name="position" intvalue="400"/>
|
||||||
</file>
|
</file>
|
||||||
<file name="com-sun-hotspot-igv-coordinator-actions-SaveAsAction.shadow">
|
<file name="com-sun-hotspot-igv-coordinator-actions-SaveAsAction.shadow">
|
||||||
<attr name="originalFile" stringvalue="Actions/File/com-sun-hotspot-igv-coordinator-actions-SaveAsAction.instance"/>
|
<attr name="originalFile" stringvalue="Actions/File/com-sun-hotspot-igv-coordinator-actions-SaveAsAction.instance"/>
|
||||||
<attr name="position" intvalue="200"/>
|
<attr name="position" intvalue="500"/>
|
||||||
</file>
|
</file>
|
||||||
<file name="com-sun-hotspot-igv-coordinator-actions-SaveAllAction.shadow">
|
<file name="com-sun-hotspot-igv-coordinator-actions-SaveAllAction.shadow">
|
||||||
<attr name="originalFile" stringvalue="Actions/File/com-sun-hotspot-igv-coordinator-actions-SaveAllAction.instance"/>
|
<attr name="originalFile" stringvalue="Actions/File/com-sun-hotspot-igv-coordinator-actions-SaveAllAction.instance"/>
|
||||||
<attr name="position" intvalue="300"/>
|
<attr name="position" intvalue="600"/>
|
||||||
</file>
|
</file>
|
||||||
<file name="SeparatorRemove.instance">
|
<file name="SeparatorRemove.instance">
|
||||||
<attr name="instanceClass" stringvalue="javax.swing.JSeparator"/>
|
<attr name="instanceClass" stringvalue="javax.swing.JSeparator"/>
|
||||||
<attr name="position" intvalue="350"/>
|
<attr name="position" intvalue="700"/>
|
||||||
</file>
|
</file>
|
||||||
<file name="com-sun-hotspot-igv-coordinator-actions-RemoveAction.shadow">
|
<file name="com-sun-hotspot-igv-coordinator-actions-RemoveAction.shadow">
|
||||||
<attr name="originalFile" stringvalue="Actions/File/com-sun-hotspot-igv-coordinator-actions-RemoveAction.instance"/>
|
<attr name="originalFile" stringvalue="Actions/File/com-sun-hotspot-igv-coordinator-actions-RemoveAction.instance"/>
|
||||||
<attr name="position" intvalue="400"/>
|
<attr name="position" intvalue="800"/>
|
||||||
</file>
|
</file>
|
||||||
<file name="com-sun-hotspot-igv-coordinator-actions-RemoveAllAction.shadow">
|
<file name="com-sun-hotspot-igv-coordinator-actions-RemoveAllAction.shadow">
|
||||||
<attr name="originalFile" stringvalue="Actions/File/com-sun-hotspot-igv-coordinator-actions-RemoveAllAction.instance"/>
|
<attr name="originalFile" stringvalue="Actions/File/com-sun-hotspot-igv-coordinator-actions-RemoveAllAction.instance"/>
|
||||||
<attr name="position" intvalue="500"/>
|
<attr name="position" intvalue="900"/>
|
||||||
</file>
|
</file>
|
||||||
<!-- Hidden menu entries from other modules -->
|
<!-- Hidden menu entries from other modules -->
|
||||||
<file name="org-netbeans-modules-editor-ExportHtmlAction.shadow_hidden"/>
|
<file name="org-netbeans-modules-editor-ExportHtmlAction.shadow_hidden"/>
|
||||||
|
@ -26,6 +26,9 @@ package com.sun.hotspot.igv.data;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public interface Folder {
|
public interface Folder {
|
||||||
|
void setName(String name);
|
||||||
|
String getName();
|
||||||
|
String getDisplayName();
|
||||||
List<? extends FolderElement> getElements();
|
List<? extends FolderElement> getElements();
|
||||||
void removeElement(FolderElement element);
|
void removeElement(FolderElement element);
|
||||||
void addElement(FolderElement group);
|
void addElement(FolderElement group);
|
||||||
|
@ -24,8 +24,10 @@
|
|||||||
package com.sun.hotspot.igv.data;
|
package com.sun.hotspot.igv.data;
|
||||||
|
|
||||||
public interface FolderElement {
|
public interface FolderElement {
|
||||||
|
ChangedEvent<? extends FolderElement> getDisplayNameChangedEvent();
|
||||||
Folder getParent();
|
void setName(String name);
|
||||||
String getName();
|
String getName();
|
||||||
|
String getDisplayName();
|
||||||
void setParent(Folder parent);
|
void setParent(Folder parent);
|
||||||
|
Folder getParent();
|
||||||
}
|
}
|
||||||
|
@ -34,10 +34,12 @@ public class GraphDocument extends Properties.Entity implements ChangedEventProv
|
|||||||
|
|
||||||
private final List<FolderElement> elements;
|
private final List<FolderElement> elements;
|
||||||
private final ChangedEvent<GraphDocument> changedEvent;
|
private final ChangedEvent<GraphDocument> changedEvent;
|
||||||
|
private String name;
|
||||||
|
|
||||||
public GraphDocument() {
|
public GraphDocument() {
|
||||||
elements = new ArrayList<>();
|
elements = new ArrayList<>();
|
||||||
changedEvent = new ChangedEvent<>(this);
|
changedEvent = new ChangedEvent<>(this);
|
||||||
|
setName("GraphDocument");
|
||||||
}
|
}
|
||||||
|
|
||||||
public void clear() {
|
public void clear() {
|
||||||
@ -61,10 +63,23 @@ public class GraphDocument extends Properties.Entity implements ChangedEventProv
|
|||||||
getChangedEvent().fire();
|
getChangedEvent().fire();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setName(String name) {
|
||||||
|
this.name = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getName() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getDisplayName() {
|
||||||
|
return getName();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
StringBuilder sb = new StringBuilder();
|
StringBuilder sb = new StringBuilder();
|
||||||
|
|
||||||
sb.append("GraphDocument: ").append(getProperties().toString()).append(" \n\n");
|
sb.append("GraphDocument: ").append(getProperties().toString()).append(" \n\n");
|
||||||
for (FolderElement g : getElements()) {
|
for (FolderElement g : getElements()) {
|
||||||
sb.append(g.toString());
|
sb.append(g.toString());
|
||||||
@ -84,6 +99,9 @@ public class GraphDocument extends Properties.Entity implements ChangedEventProv
|
|||||||
if (elements.remove(element)) {
|
if (elements.remove(element)) {
|
||||||
getChangedEvent().fire();
|
getChangedEvent().fire();
|
||||||
}
|
}
|
||||||
|
for (FolderElement folderElement : elements) {
|
||||||
|
folderElement.getDisplayNameChangedEvent().fire();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -34,6 +34,8 @@ public class Group extends Properties.Entity implements ChangedEventProvider<Gro
|
|||||||
private final List<InputGraph> graphs;
|
private final List<InputGraph> graphs;
|
||||||
private InputMethod method;
|
private InputMethod method;
|
||||||
private final transient ChangedEvent<Group> changedEvent;
|
private final transient ChangedEvent<Group> changedEvent;
|
||||||
|
private final ChangedEvent<Group> displayNameChangedEvent = new ChangedEvent<>(this);
|
||||||
|
|
||||||
private Folder parent;
|
private Folder parent;
|
||||||
|
|
||||||
public Group(Folder parent) {
|
public Group(Folder parent) {
|
||||||
@ -72,6 +74,10 @@ public class Group extends Properties.Entity implements ChangedEventProvider<Gro
|
|||||||
if (graphs.remove((InputGraph) element)) {
|
if (graphs.remove((InputGraph) element)) {
|
||||||
getChangedEvent().fire();
|
getChangedEvent().fire();
|
||||||
}
|
}
|
||||||
|
for (InputGraph inputGraph : graphs) {
|
||||||
|
assert inputGraph.getDisplayNameChangedEvent() != null;
|
||||||
|
inputGraph.getDisplayNameChangedEvent().fire();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -102,14 +108,29 @@ public class Group extends Properties.Entity implements ChangedEventProvider<Gro
|
|||||||
return sb.toString();
|
return sb.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ChangedEvent<Group> getDisplayNameChangedEvent() {
|
||||||
|
return displayNameChangedEvent;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setName(String name) {
|
||||||
|
getProperties().setProperty("name", name);
|
||||||
|
displayNameChangedEvent.fire();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return getProperties().get("name");
|
return getProperties().get("name");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getDisplayName() {
|
||||||
|
return getParent().getElements().indexOf(this)+1 + " - " + getName();
|
||||||
|
}
|
||||||
|
|
||||||
public String getType() {
|
public String getType() {
|
||||||
return getProperties().get("type");
|
return getProperties().get("type");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
InputGraph getPrev(InputGraph graph) {
|
InputGraph getPrev(InputGraph graph) {
|
||||||
|
@ -38,29 +38,35 @@ public class InputGraph extends Properties.Entity implements FolderElement {
|
|||||||
private final Map<String, InputBlock> blocks;
|
private final Map<String, InputBlock> blocks;
|
||||||
private final List<InputBlockEdge> blockEdges;
|
private final List<InputBlockEdge> blockEdges;
|
||||||
private final Map<Integer, InputBlock> nodeToBlock;
|
private final Map<Integer, InputBlock> nodeToBlock;
|
||||||
private boolean isDiffGraph;
|
private final boolean isDiffGraph;
|
||||||
private InputGraph firstGraph;
|
private final InputGraph firstGraph;
|
||||||
private InputGraph secondGraph;
|
private final InputGraph secondGraph;
|
||||||
|
private final ChangedEvent<InputGraph> displayNameChangedEvent = new ChangedEvent<>(this);
|
||||||
|
|
||||||
public InputGraph(InputGraph firstGraph, InputGraph secondGraph) {
|
public InputGraph(InputGraph firstGraph, InputGraph secondGraph) {
|
||||||
this(firstGraph.getName() + " Δ " + secondGraph.getName());
|
this(firstGraph.getName() + " Δ " + secondGraph.getName(), firstGraph, secondGraph);
|
||||||
assert !firstGraph.isDiffGraph() && !secondGraph.isDiffGraph();
|
assert !firstGraph.isDiffGraph() && !secondGraph.isDiffGraph();
|
||||||
this.firstGraph = firstGraph;
|
|
||||||
this.secondGraph = secondGraph;
|
|
||||||
isDiffGraph = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public InputGraph(String name) {
|
public InputGraph(String name) {
|
||||||
|
this(name, null, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
private InputGraph(String name, InputGraph firstGraph, InputGraph secondGraph) {
|
||||||
setName(name);
|
setName(name);
|
||||||
nodes = new LinkedHashMap<>();
|
nodes = new LinkedHashMap<>();
|
||||||
edges = new ArrayList<>();
|
edges = new ArrayList<>();
|
||||||
blocks = new LinkedHashMap<>();
|
blocks = new LinkedHashMap<>();
|
||||||
blockEdges = new ArrayList<>();
|
blockEdges = new ArrayList<>();
|
||||||
nodeToBlock = new LinkedHashMap<>();
|
nodeToBlock = new LinkedHashMap<>();
|
||||||
firstGraph = null;
|
isDiffGraph = firstGraph != null && secondGraph != null;
|
||||||
secondGraph = null;
|
this.firstGraph = firstGraph;
|
||||||
isDiffGraph = false;
|
this.secondGraph = secondGraph;
|
||||||
|
if (isDiffGraph) {
|
||||||
|
this.firstGraph.getDisplayNameChangedEvent().addListener(l -> displayNameChangedEvent.fire());
|
||||||
|
this.secondGraph.getDisplayNameChangedEvent().addListener(l -> displayNameChangedEvent.fire());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isDiffGraph() {
|
public boolean isDiffGraph() {
|
||||||
@ -81,6 +87,9 @@ public class InputGraph extends Properties.Entity implements FolderElement {
|
|||||||
if (parent instanceof Group) {
|
if (parent instanceof Group) {
|
||||||
assert this.parentGroup == null;
|
assert this.parentGroup == null;
|
||||||
this.parentGroup = (Group) parent;
|
this.parentGroup = (Group) parent;
|
||||||
|
assert displayNameChangedEvent != null;
|
||||||
|
assert this.parentGroup.getDisplayNameChangedEvent() != null;
|
||||||
|
this.parentGroup.getDisplayNameChangedEvent().addListener(l -> displayNameChangedEvent.fire());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -220,8 +229,15 @@ public class InputGraph extends Properties.Entity implements FolderElement {
|
|||||||
return parentGroup.getPrev(this);
|
return parentGroup.getPrev(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setName(String name) {
|
@Override
|
||||||
this.getProperties().setProperty("name", name);
|
public ChangedEvent<InputGraph> getDisplayNameChangedEvent() {
|
||||||
|
return displayNameChangedEvent;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setName(String name) {
|
||||||
|
getProperties().setProperty("name", name);
|
||||||
|
displayNameChangedEvent.fire();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -229,6 +245,19 @@ public class InputGraph extends Properties.Entity implements FolderElement {
|
|||||||
return getProperties().get("name");
|
return getProperties().get("name");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getDisplayName() {
|
||||||
|
if (isDiffGraph) {
|
||||||
|
return firstGraph.getDisplayName() + " Δ " + secondGraph.getDisplayName();
|
||||||
|
} else {
|
||||||
|
return getIndex()+1 + ". " + getName();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getIndex() {
|
||||||
|
return getGroup().getGraphs().indexOf(this);
|
||||||
|
}
|
||||||
|
|
||||||
public Collection<InputNode> getNodes() {
|
public Collection<InputNode> getNodes() {
|
||||||
return Collections.unmodifiableCollection(nodes.values());
|
return Collections.unmodifiableCollection(nodes.values());
|
||||||
}
|
}
|
||||||
|
@ -37,6 +37,7 @@ import com.sun.hotspot.igv.settings.Settings;
|
|||||||
import com.sun.hotspot.igv.util.RangeSliderModel;
|
import com.sun.hotspot.igv.util.RangeSliderModel;
|
||||||
import java.awt.Color;
|
import java.awt.Color;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
import java.util.function.Consumer;
|
||||||
import org.openide.util.Lookup;
|
import org.openide.util.Lookup;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -45,7 +46,6 @@ import org.openide.util.Lookup;
|
|||||||
*/
|
*/
|
||||||
public class DiagramViewModel extends RangeSliderModel implements ChangedListener<RangeSliderModel> {
|
public class DiagramViewModel extends RangeSliderModel implements ChangedListener<RangeSliderModel> {
|
||||||
|
|
||||||
// Warning: Update setData method if fields are added
|
|
||||||
private final Group group;
|
private final Group group;
|
||||||
private ArrayList<InputGraph> graphs;
|
private ArrayList<InputGraph> graphs;
|
||||||
private Set<Integer> hiddenNodes;
|
private Set<Integer> hiddenNodes;
|
||||||
@ -58,6 +58,7 @@ public class DiagramViewModel extends RangeSliderModel implements ChangedListene
|
|||||||
private final ChangedEvent<DiagramViewModel> graphChangedEvent;
|
private final ChangedEvent<DiagramViewModel> graphChangedEvent;
|
||||||
private final ChangedEvent<DiagramViewModel> selectedNodesChangedEvent;
|
private final ChangedEvent<DiagramViewModel> selectedNodesChangedEvent;
|
||||||
private final ChangedEvent<DiagramViewModel> hiddenNodesChangedEvent;
|
private final ChangedEvent<DiagramViewModel> hiddenNodesChangedEvent;
|
||||||
|
private ChangedListener<InputGraph> titleChangedListener = g -> {};
|
||||||
private boolean showSea;
|
private boolean showSea;
|
||||||
private boolean showBlocks;
|
private boolean showBlocks;
|
||||||
private boolean showCFG;
|
private boolean showCFG;
|
||||||
@ -390,6 +391,9 @@ public class DiagramViewModel extends RangeSliderModel implements ChangedListene
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void changed(RangeSliderModel source) {
|
public void changed(RangeSliderModel source) {
|
||||||
|
if (cachedInputGraph != null) {
|
||||||
|
cachedInputGraph.getDisplayNameChangedEvent().removeListener(titleChangedListener);
|
||||||
|
}
|
||||||
if (getFirstGraph() != getSecondGraph()) {
|
if (getFirstGraph() != getSecondGraph()) {
|
||||||
cachedInputGraph = Difference.createDiffGraph(getFirstGraph(), getSecondGraph());
|
cachedInputGraph = Difference.createDiffGraph(getFirstGraph(), getSecondGraph());
|
||||||
} else {
|
} else {
|
||||||
@ -397,6 +401,12 @@ public class DiagramViewModel extends RangeSliderModel implements ChangedListene
|
|||||||
}
|
}
|
||||||
rebuildDiagram();
|
rebuildDiagram();
|
||||||
graphChangedEvent.fire();
|
graphChangedEvent.fire();
|
||||||
|
assert titleChangedListener != null;
|
||||||
|
cachedInputGraph.getDisplayNameChangedEvent().addListener(titleChangedListener);
|
||||||
|
}
|
||||||
|
|
||||||
|
void addTitleCallback(Consumer<InputGraph> titleCallback) {
|
||||||
|
titleChangedListener = titleCallback::accept;
|
||||||
}
|
}
|
||||||
|
|
||||||
void close() {
|
void close() {
|
||||||
|
@ -135,12 +135,6 @@ public final class EditorTopComponent extends TopComponent {
|
|||||||
content.add(diagramViewModel);
|
content.add(diagramViewModel);
|
||||||
associateLookup(new ProxyLookup(scene.getLookup(), new AbstractLookup(graphContent), new AbstractLookup(content)));
|
associateLookup(new ProxyLookup(scene.getLookup(), new AbstractLookup(graphContent), new AbstractLookup(content)));
|
||||||
|
|
||||||
diagramViewModel.getDiagramChangedEvent().addListener(model -> {
|
|
||||||
setDisplayName(model.getGraph().getName());
|
|
||||||
setToolTipText(model.getGroup().getName());
|
|
||||||
graphContent.set(Collections.singletonList(new EditorInputGraphProvider(this)), null);
|
|
||||||
});
|
|
||||||
|
|
||||||
Group group = diagramViewModel.getGroup();
|
Group group = diagramViewModel.getGroup();
|
||||||
group.getChangedEvent().addListener(g -> closeOnRemovedOrEmptyGroup());
|
group.getChangedEvent().addListener(g -> closeOnRemovedOrEmptyGroup());
|
||||||
if (group.getParent() instanceof GraphDocument) {
|
if (group.getParent() instanceof GraphDocument) {
|
||||||
@ -148,6 +142,17 @@ public final class EditorTopComponent extends TopComponent {
|
|||||||
doc.getChangedEvent().addListener(d -> closeOnRemovedOrEmptyGroup());
|
doc.getChangedEvent().addListener(d -> closeOnRemovedOrEmptyGroup());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
diagramViewModel.addTitleCallback(changedGraph -> {
|
||||||
|
setDisplayName(changedGraph.getDisplayName());
|
||||||
|
setToolTipText(diagramViewModel.getGroup().getDisplayName());
|
||||||
|
});
|
||||||
|
|
||||||
|
diagramViewModel.getDiagramChangedEvent().addListener(model -> {
|
||||||
|
setDisplayName(model.getGraph().getDisplayName());
|
||||||
|
setToolTipText(model.getGroup().getDisplayName());
|
||||||
|
graphContent.set(Collections.singletonList(new EditorInputGraphProvider(this)), null);
|
||||||
|
});
|
||||||
|
|
||||||
cardLayout = new CardLayout();
|
cardLayout = new CardLayout();
|
||||||
centerPanel = new JPanel();
|
centerPanel = new JPanel();
|
||||||
centerPanel.setLayout(cardLayout);
|
centerPanel.setLayout(cardLayout);
|
||||||
|
@ -23,7 +23,7 @@
|
|||||||
<folder name="File">
|
<folder name="File">
|
||||||
<file name="ExportActionSeparator.instance">
|
<file name="ExportActionSeparator.instance">
|
||||||
<attr name="instanceClass" stringvalue="javax.swing.JSeparator"/>
|
<attr name="instanceClass" stringvalue="javax.swing.JSeparator"/>
|
||||||
<attr name="position" intvalue="700"/>
|
<attr name="position" intvalue="2000"/>
|
||||||
</file>
|
</file>
|
||||||
</folder>
|
</folder>
|
||||||
</folder>
|
</folder>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user