Skip to content

Commit d02bfdf

Browse files
8297032: IGV: shortcut to center selected nodes
Reviewed-by: chagedorn, rcastanedalo
1 parent 35acb89 commit d02bfdf

File tree

3 files changed

+271
-2
lines changed

3 files changed

+271
-2
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
/*
2+
* Copyright (c) 2022, 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.view.actions;
25+
26+
import com.sun.hotspot.igv.view.DiagramViewModel;
27+
import com.sun.hotspot.igv.view.EditorTopComponent;
28+
import org.openide.awt.ActionID;
29+
import org.openide.awt.ActionReference;
30+
import org.openide.awt.ActionReferences;
31+
import org.openide.awt.ActionRegistration;
32+
import org.openide.util.NbBundle;
33+
34+
@ActionID(category = "View", id = "com.sun.hotspot.igv.view.actions.CenterSelectedNodesAction")
35+
@ActionRegistration(displayName = "#CTL_CenterSelectedNodesAction")
36+
@ActionReferences({
37+
@ActionReference(path = "Menu/View", position = 600),
38+
@ActionReference(path = "Shortcuts", name = "D-9")
39+
})
40+
@NbBundle.Messages({
41+
"CTL_CenterSelectedNodesAction=Center selected nodes",
42+
"HINT_CenterSelectedNodesAction=Center the selected nodes"
43+
})
44+
public final class CenterSelectedNodesAction extends ModelAwareAction {
45+
46+
@Override
47+
protected String iconResource() {
48+
return "com/sun/hotspot/igv/view/images/centerSelectedNodes.svg"; // NOI18N
49+
}
50+
51+
@Override
52+
public String getName() {
53+
return NbBundle.getMessage(NextDiagramAction.class, "CTL_CenterSelectedNodesAction");
54+
}
55+
56+
@Override
57+
protected String getDescription() {
58+
return NbBundle.getMessage(NextDiagramAction.class, "HINT_CenterSelectedNodesAction");
59+
}
60+
61+
@Override
62+
public void performAction(DiagramViewModel model) {
63+
EditorTopComponent editor = EditorTopComponent.findEditorForGraph(model.getGraph());
64+
if (editor != null) {
65+
editor.centerSelectedNodes();
66+
}
67+
}
68+
69+
@Override
70+
public boolean isEnabled(DiagramViewModel model) {
71+
return !model.getSelectedNodes().isEmpty();
72+
}
73+
}

src/utils/IdealGraphVisualizer/View/src/main/java/com/sun/hotspot/igv/view/actions/ZoomResetAction.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,8 @@
4141
@ActionReference(path = "Shortcuts", name = "D-0")
4242
})
4343
@NbBundle.Messages({
44-
"CTL_ZoomResetAction=Reset zoom (100%",
45-
"HINT_ZoomResetAction=Rest the zoom level to 100%"
44+
"CTL_ZoomResetAction=Reset zoom (100%)",
45+
"HINT_ZoomResetAction=Reset the zoom level to 100%"
4646
})
4747
public final class ZoomResetAction extends CallableSystemAction {
4848

0 commit comments

Comments
 (0)