Mercurial > hg > graal-compiler
comparison visualizer/Bytecodes/src/com/sun/hotspot/igv/bytecodes/BytecodeNode.java @ 4512:015fb895586b
Moved visualizer to new directory.
author | Thomas Wuerthinger <thomas.wuerthinger@oracle.com> |
---|---|
date | Tue, 07 Feb 2012 22:41:09 +0100 |
parents | |
children | be428fe2d86c |
comparison
equal
deleted
inserted
replaced
4511:6cb549627941 | 4512:015fb895586b |
---|---|
1 /* | |
2 * Copyright (c) 2008, Oracle and/or its affiliates. All rights reserved. | |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. | |
4 * | |
5 * This code is free software; you can redistribute it and/or modify it | |
6 * under the terms of the GNU General Public License version 2 only, as | |
7 * published by the Free Software Foundation. | |
8 * | |
9 * This code is distributed in the hope that it will be useful, but WITHOUT | |
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
12 * version 2 for more details (a copy is included in the LICENSE file that | |
13 * accompanied this code). | |
14 * | |
15 * You should have received a copy of the GNU General Public License version | |
16 * 2 along with this work; if not, write to the Free Software Foundation, | |
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. | |
18 * | |
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA | |
20 * or visit www.oracle.com if you need additional information or have any | |
21 * questions. | |
22 * | |
23 */ | |
24 package com.sun.hotspot.igv.bytecodes; | |
25 | |
26 import com.sun.hotspot.igv.data.InputBytecode; | |
27 import com.sun.hotspot.igv.data.InputGraph; | |
28 import com.sun.hotspot.igv.data.InputNode; | |
29 import com.sun.hotspot.igv.data.Properties; | |
30 import com.sun.hotspot.igv.data.Properties.StringPropertyMatcher; | |
31 import java.awt.Image; | |
32 import java.util.LinkedHashSet; | |
33 import java.util.List; | |
34 import java.util.Set; | |
35 import javax.swing.Action; | |
36 import org.openide.nodes.AbstractNode; | |
37 import org.openide.nodes.Children; | |
38 import org.openide.nodes.Node; | |
39 import org.openide.util.ImageUtilities; | |
40 | |
41 /** | |
42 * | |
43 * @author Thomas Wuerthinger | |
44 */ | |
45 public class BytecodeNode extends AbstractNode { | |
46 | |
47 private Set<InputNode> nodes; | |
48 | |
49 public BytecodeNode(InputBytecode bytecode, InputGraph graph, String bciValue) { | |
50 | |
51 super(Children.LEAF); | |
52 this.setDisplayName(bytecode.getBci() + " " + bytecode.getName()); | |
53 | |
54 bciValue = bytecode.getBci() + " " + bciValue; | |
55 bciValue = bciValue.trim(); | |
56 | |
57 Properties.PropertySelector<InputNode> selector = new Properties.PropertySelector<>(graph.getNodes()); | |
58 StringPropertyMatcher matcher = new StringPropertyMatcher("bci", bciValue); | |
59 List<InputNode> nodeList = selector.selectMultiple(matcher); | |
60 if (nodeList.size() > 0) { | |
61 nodes = new LinkedHashSet<>(); | |
62 for (InputNode n : nodeList) { | |
63 nodes.add(n); | |
64 } | |
65 this.setDisplayName(this.getDisplayName() + " (" + nodes.size() + " nodes)"); | |
66 } | |
67 } | |
68 | |
69 @Override | |
70 public Image getIcon(int i) { | |
71 if (nodes != null) { | |
72 return ImageUtilities.loadImage("com/sun/hotspot/igv/bytecodes/images/link.png"); | |
73 } else { | |
74 return ImageUtilities.loadImage("com/sun/hotspot/igv/bytecodes/images/bytecode.png"); | |
75 } | |
76 } | |
77 | |
78 @Override | |
79 public Image getOpenedIcon(int i) { | |
80 return getIcon(i); | |
81 } | |
82 | |
83 @Override | |
84 public Action[] getActions(boolean b) { | |
85 return new Action[]{(Action) SelectBytecodesAction.findObject(SelectBytecodesAction.class, true)}; | |
86 } | |
87 | |
88 @Override | |
89 public Action getPreferredAction() { | |
90 return (Action) SelectBytecodesAction.findObject(SelectBytecodesAction.class, true); | |
91 } | |
92 | |
93 @Override | |
94 @SuppressWarnings("unchecked") | |
95 public <T extends Node.Cookie> T getCookie(Class<T> aClass) { | |
96 if (aClass == SelectBytecodesCookie.class && nodes != null) { | |
97 return (T) (new SelectBytecodesCookie(nodes)); | |
98 } | |
99 return super.getCookie(aClass); | |
100 } | |
101 } |