# HG changeset patch # User Thomas Wuerthinger # Date 1328111966 -3600 # Node ID 35569a1b4f62014cdae83378df8b1a2d9c2864a7 # Parent 897ea0dd3ce1a9ed5522192fcdf9d4aa747d7aa8 More clean up around editor top component. diff -r 897ea0dd3ce1 -r 35569a1b4f62 src/share/tools/IdealGraphVisualizer/View/src/com/sun/hotspot/igv/view/DiagramScene.java --- a/src/share/tools/IdealGraphVisualizer/View/src/com/sun/hotspot/igv/view/DiagramScene.java Wed Feb 01 16:17:16 2012 +0100 +++ b/src/share/tools/IdealGraphVisualizer/View/src/com/sun/hotspot/igv/view/DiagramScene.java Wed Feb 01 16:59:26 2012 +0100 @@ -354,7 +354,7 @@ boolean b = highlightedCoordinatorListener.isEnabled(); highlightedCoordinatorListener.setEnabled(false); SelectionCoordinator.getInstance().setHighlightedObjects(nodeHighlighting); - highlightedCoordinatorListener.setEnabled(true); + highlightedCoordinatorListener.setEnabled(b); } @Override @@ -451,7 +451,7 @@ } public boolean isAllVisible() { - return getModel().getHiddenNodes().size() == 0; + return getModel().getHiddenNodes().isEmpty(); } public Action createGotoAction(final Figure f) { @@ -746,7 +746,6 @@ newPredecessor = w; connectionLayer.addChild(w); - this.addObject(new ConnectionSet(connectionList), w); w.getActions().addAction(hoverAction); } @@ -755,26 +754,6 @@ } @Override - public void setInteractionMode(InteractionMode mode) { - panAction.setEnabled(mode == InteractionMode.PANNING); - // When panAction is not enabled, it does not consume the event - // and the selection action handles it instead - } - - private class ConnectionSet { - - private Set connections; - - public ConnectionSet(Collection connections) { - connections = new HashSet<>(connections); - } - - public Set getConnectionSet() { - return Collections.unmodifiableSet(connections); - } - } - - @Override public Lookup getLookup() { return lookup; } diff -r 897ea0dd3ce1 -r 35569a1b4f62 src/share/tools/IdealGraphVisualizer/View/src/com/sun/hotspot/igv/view/DiagramViewer.java --- a/src/share/tools/IdealGraphVisualizer/View/src/com/sun/hotspot/igv/view/DiagramViewer.java Wed Feb 01 16:17:16 2012 +0100 +++ b/src/share/tools/IdealGraphVisualizer/View/src/com/sun/hotspot/igv/view/DiagramViewer.java Wed Feb 01 16:59:26 2012 +0100 @@ -39,11 +39,6 @@ */ interface DiagramViewer { - enum InteractionMode { - SELECTION, - PANNING, - } - public void paint(Graphics2D svgGenerator); public Lookup getLookup(); @@ -67,7 +62,4 @@ public void setSelection(Collection
list); public void centerFigures(List
list); - - public void setInteractionMode(InteractionMode mode); - } diff -r 897ea0dd3ce1 -r 35569a1b4f62 src/share/tools/IdealGraphVisualizer/View/src/com/sun/hotspot/igv/view/EditorTopComponent.java --- a/src/share/tools/IdealGraphVisualizer/View/src/com/sun/hotspot/igv/view/EditorTopComponent.java Wed Feb 01 16:17:16 2012 +0100 +++ b/src/share/tools/IdealGraphVisualizer/View/src/com/sun/hotspot/igv/view/EditorTopComponent.java Wed Feb 01 16:59:26 2012 +0100 @@ -77,19 +77,9 @@ private DiagramViewer scene; private InstanceContent content; private InstanceContent graphContent; - private OverviewAction overviewAction; private PredSuccAction predSuccAction; - private SelectionModeAction selectionModeAction; - private PanModeAction panModeAction; - private boolean notFirstTime; - private JComponent satelliteComponent; - private JPanel centerPanel; - private CardLayout cardLayout; private RangeSlider rangeSlider; - private JToggleButton overviewButton; private static final String PREFERRED_ID = "EditorTopComponent"; - private static final String SATELLITE_STRING = "satellite"; - private static final String SCENE_STRING = "scene"; private DiagramViewModel rangeSliderModel; private ExportCookie exportCookie = new ExportCookie() { @@ -192,7 +182,6 @@ rangeSliderModel = new DiagramViewModel(diagram.getGraph().getGroup(), filterChain, sequence); rangeSlider = new RangeSlider(); rangeSlider.setModel(rangeSliderModel); - // this.add(BorderLayout.WEST, rangeSlider); scene = new DiagramScene(actions, rangeSliderModel); content = new InstanceContent(); @@ -205,8 +194,8 @@ rangeSliderModel.getDiagramChangedEvent().addListener(diagramChangedListener); rangeSliderModel.selectGraph(diagram.getGraph()); + toolBar.add(PrevDiagramAction.get(PrevDiagramAction.class)); toolBar.add(NextDiagramAction.get(NextDiagramAction.class)); - toolBar.add(PrevDiagramAction.get(PrevDiagramAction.class)); toolBar.addSeparator(); toolBar.add(ExtractAction.get(ExtractAction.class)); toolBar.add(ShowAllAction.get(HideAction.class)); @@ -215,12 +204,6 @@ toolBar.add(ShowAllAction.get(ZoomInAction.class)); toolBar.add(ShowAllAction.get(ZoomOutAction.class)); - overviewAction = new OverviewAction(); - overviewButton = new JToggleButton(overviewAction); - overviewButton.setSelected(false); - toolBar.add(overviewButton); - overviewAction.addPropertyChangeListener(this); - predSuccAction = new PredSuccAction(); JToggleButton button = new JToggleButton(predSuccAction); button.setSelected(true); @@ -232,21 +215,6 @@ toolBar.add(RedoAction.get(RedoAction.class)); toolBar.addSeparator(); - ButtonGroup interactionButtons = new ButtonGroup(); - - panModeAction = new PanModeAction(); - panModeAction.setSelected(true); - button = new JToggleButton(panModeAction); - button.setSelected(true); - interactionButtons.add(button); - toolBar.add(button); - panModeAction.addPropertyChangeListener(this); - - selectionModeAction = new SelectionModeAction(); - button = new JToggleButton(selectionModeAction); - interactionButtons.add(button); - toolBar.add(button); - selectionModeAction.addPropertyChangeListener(this); toolBar.add(Box.createHorizontalGlue()); Action action = Utilities.actionsForPath("QuickSearchShadow").get(0); @@ -254,90 +222,19 @@ quicksearch.setMinimumSize(quicksearch.getPreferredSize()); // necessary for GTK LAF toolBar.add(quicksearch); - centerPanel = new JPanel(); - JSplitPane splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, - new JScrollPane(rangeSlider), centerPanel); + new JScrollPane(rangeSlider), scene.getComponent()); splitPane.setOneTouchExpandable(true); splitPane.setDividerLocation(250); this.add(splitPane, BorderLayout.CENTER); - cardLayout = new CardLayout(); - centerPanel.setLayout(cardLayout); - centerPanel.add(SCENE_STRING, scene.getComponent()); - centerPanel.setBackground(Color.WHITE); - satelliteComponent = scene.createSatelliteView(); - satelliteComponent.setSize(200, 200); - centerPanel.add(SATELLITE_STRING, satelliteComponent); - - // TODO: Fix the hot key for entering the satellite view - this.addKeyListener(keyListener); - - scene.getComponent().addHierarchyBoundsListener(new HierarchyBoundsListener() { - - @Override - public void ancestorMoved(HierarchyEvent e) { - } - - @Override - public void ancestorResized(HierarchyEvent e) { - if (!notFirstTime && scene.getComponent().getBounds().width > 0) { - notFirstTime = true; - SwingUtilities.invokeLater(new Runnable() { - - @Override - public void run() { - EditorTopComponent.this.scene.initialize(); - } - }); - } - } - }); - - if (diagram.getGraph().getGroup().getGraphsCount() == 1) { - rangeSlider.setVisible(false); - } - updateDisplayName(); } - private KeyListener keyListener = new KeyListener() { - - @Override - public void keyTyped(KeyEvent e) { - } - - @Override - public void keyPressed(KeyEvent e) { - if (e.getKeyCode() == KeyEvent.VK_S) { - EditorTopComponent.this.overviewButton.setSelected(true); - EditorTopComponent.this.overviewAction.setState(true); - } - } - - @Override - public void keyReleased(KeyEvent e) { - if (e.getKeyCode() == KeyEvent.VK_S) { - EditorTopComponent.this.overviewButton.setSelected(false); - EditorTopComponent.this.overviewAction.setState(false); - } - } - }; public DiagramViewModel getDiagramModel() { return rangeSliderModel; } - private void showSatellite() { - cardLayout.show(centerPanel, SATELLITE_STRING); - satelliteComponent.requestFocus(); - - } - - private void showScene() { - cardLayout.show(centerPanel, SCENE_STRING); - scene.getComponent().requestFocus(); - } - public void zoomOut() { scene.zoomOut(); } @@ -467,19 +364,6 @@ if (evt.getSource() == this.predSuccAction) { boolean b = (Boolean) predSuccAction.getValue(PredSuccAction.STATE); this.getModel().setShowNodeHull(b); - } else if (evt.getSource() == this.overviewAction) { - boolean b = (Boolean) overviewAction.getValue(OverviewAction.STATE); - if (b) { - showSatellite(); - } else { - showScene(); - } - } else if (evt.getSource() == this.selectionModeAction || evt.getSource() == this.panModeAction) { - if (panModeAction.isSelected()) { - scene.setInteractionMode(DiagramViewer.InteractionMode.PANNING); - } else if (selectionModeAction.isSelected()) { - scene.setInteractionMode(DiagramViewer.InteractionMode.SELECTION); - } } else { assert false : "Unknown event source"; } diff -r 897ea0dd3ce1 -r 35569a1b4f62 src/share/tools/IdealGraphVisualizer/View/src/com/sun/hotspot/igv/view/actions/OverviewAction.java --- a/src/share/tools/IdealGraphVisualizer/View/src/com/sun/hotspot/igv/view/actions/OverviewAction.java Wed Feb 01 16:17:16 2012 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,60 +0,0 @@ -/* - * Copyright (c) 2008, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - * - */ -package com.sun.hotspot.igv.view.actions; - -import java.awt.event.ActionEvent; -import javax.swing.AbstractAction; -import javax.swing.Action; -import javax.swing.ImageIcon; -import org.openide.util.ImageUtilities; - -/** - * - * @author Thomas Wuerthinger - */ -public class OverviewAction extends AbstractAction { - - private boolean state; - public static final String STATE = "state"; - - public OverviewAction() { - putValue(AbstractAction.SMALL_ICON, new ImageIcon(ImageUtilities.loadImage(iconResource()))); - putValue(Action.SHORT_DESCRIPTION, "Show satellite view of whole graph"); - setState(false); - } - - @Override - public void actionPerformed(ActionEvent ev) { - setState(!state); - } - - public void setState(boolean b) { - this.putValue(STATE, b); - this.state = b; - } - - protected String iconResource() { - return "com/sun/hotspot/igv/view/images/overview.png"; - } -} diff -r 897ea0dd3ce1 -r 35569a1b4f62 src/share/tools/IdealGraphVisualizer/View/src/com/sun/hotspot/igv/view/actions/PanModeAction.java --- a/src/share/tools/IdealGraphVisualizer/View/src/com/sun/hotspot/igv/view/actions/PanModeAction.java Wed Feb 01 16:17:16 2012 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,59 +0,0 @@ -/* - * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - * - */ -package com.sun.hotspot.igv.view.actions; - -import java.awt.event.ActionEvent; -import javax.swing.AbstractAction; -import javax.swing.Action; -import javax.swing.ImageIcon; -import org.openide.util.ImageUtilities; - -public class PanModeAction extends AbstractAction { - - private boolean state; - - public PanModeAction() { - putValue(AbstractAction.SMALL_ICON, new ImageIcon(ImageUtilities.loadImage(iconResource()))); - putValue(SELECTED_KEY, false); - putValue(Action.SHORT_DESCRIPTION, "Panning mode"); - } - - public boolean isSelected() { - return (Boolean)getValue(SELECTED_KEY); - } - - public void setSelected(boolean b) { - if (isSelected() != b) { - this.putValue(SELECTED_KEY, b); - } - } - - protected String iconResource() { - return "com/sun/hotspot/igv/view/images/pan_mode.png"; - } - - @Override - public void actionPerformed(ActionEvent e) { - } -} diff -r 897ea0dd3ce1 -r 35569a1b4f62 src/share/tools/IdealGraphVisualizer/View/src/com/sun/hotspot/igv/view/actions/SelectionModeAction.java --- a/src/share/tools/IdealGraphVisualizer/View/src/com/sun/hotspot/igv/view/actions/SelectionModeAction.java Wed Feb 01 16:17:16 2012 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,57 +0,0 @@ -/* - * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - * - */ -package com.sun.hotspot.igv.view.actions; - -import java.awt.event.ActionEvent; -import javax.swing.AbstractAction; -import javax.swing.Action; -import javax.swing.ImageIcon; -import org.openide.util.ImageUtilities; - -public class SelectionModeAction extends AbstractAction { - - public SelectionModeAction() { - putValue(AbstractAction.SMALL_ICON, new ImageIcon(ImageUtilities.loadImage(iconResource()))); - putValue(SELECTED_KEY, false); - putValue(Action.SHORT_DESCRIPTION, "Selection mode"); - } - - public boolean isSelected() { - return (Boolean)getValue(SELECTED_KEY); - } - - public void setSelected(boolean b) { - if (isSelected() != b) { - this.putValue(SELECTED_KEY, b); - } - } - - protected String iconResource() { - return "com/sun/hotspot/igv/view/images/selection_mode.png"; - } - - @Override - public void actionPerformed(ActionEvent e) { - } -}