8292669: IGV: Search not useable when in Overflow Toolbar

Co-authored-by: Christian Hagedorn <chagedorn@openjdk.org>
Co-authored-by: Tobias Holenstein <tholenstein@openjdk.org>
Reviewed-by: chagedorn, rcastanedalo
This commit is contained in:
Tobias Holenstein 2022-08-26 13:37:14 +00:00
parent 4732abf7f4
commit 2b803493ba
3 changed files with 56 additions and 51 deletions

View File

@ -33,11 +33,13 @@ import com.sun.hotspot.igv.data.services.InputGraphProvider;
import com.sun.hotspot.igv.util.LookupHistory;
import com.sun.hotspot.igv.view.EditorTopComponent;
import java.awt.BorderLayout;
import java.awt.Dimension;
import java.io.IOException;
import java.io.ObjectInput;
import java.io.ObjectOutput;
import java.io.Serializable;
import javax.swing.*;
import javax.swing.SwingUtilities;
import javax.swing.UIManager;
import javax.swing.border.Border;
import org.openide.ErrorManager;
import org.openide.actions.GarbageCollectAction;
@ -46,12 +48,7 @@ import org.openide.awt.ToolbarPool;
import org.openide.explorer.ExplorerManager;
import org.openide.explorer.ExplorerUtils;
import org.openide.explorer.view.BeanTreeView;
import org.openide.util.Exceptions;
import org.openide.util.Lookup;
import org.openide.util.LookupEvent;
import org.openide.util.LookupListener;
import org.openide.util.NbBundle;
import org.openide.util.Utilities;
import org.openide.util.*;
import org.openide.util.actions.NodeAction;
import org.openide.windows.TopComponent;
import org.openide.windows.WindowManager;
@ -97,8 +94,9 @@ public final class OutlineTopComponent extends TopComponent implements ExplorerM
private void initToolbar() {
Toolbar toolbar = new Toolbar();
Border b = (Border) UIManager.get("Nb.Editor.Toolbar.border"); //NOI18N
toolbar.setBorder(b);
toolbar.setBorder((Border) UIManager.get("Nb.Editor.Toolbar.border")); //NOI18N
toolbar.setMinimumSize(new Dimension(0,0)); // MacOS BUG with ToolbarWithOverflow
this.add(toolbar, BorderLayout.NORTH);
toolbar.add(ImportAction.get(ImportAction.class));

View File

@ -31,13 +31,17 @@ import com.sun.hotspot.igv.filter.FilterChain;
import com.sun.hotspot.igv.filter.FilterSetting;
import com.sun.hotspot.igv.filterwindow.actions.*;
import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.*;
import java.util.*;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.script.*;
import javax.script.ScriptContext;
import javax.script.ScriptEngine;
import javax.script.ScriptEngineManager;
import javax.script.ScriptException;
import javax.swing.JComboBox;
import javax.swing.UIManager;
import javax.swing.border.Border;
@ -360,8 +364,9 @@ public final class FilterTopComponent extends TopComponent implements LookupList
ToolbarPool.getDefault().setPreferredIconSize(16);
Toolbar toolBar = new Toolbar();
Border b = (Border) UIManager.get("Nb.Editor.Toolbar.border"); //NOI18N
toolBar.setBorder(b);
toolBar.setBorder((Border) UIManager.get("Nb.Editor.Toolbar.border")); //NOI18N
toolBar.setMinimumSize(new Dimension(0,0)); // MacOS BUG with ToolbarWithOverflow
comboBox = new JComboBox();
toolBar.add(comboBox);
this.add(toolBar, BorderLayout.NORTH);

View File

@ -23,13 +23,14 @@
*/
package com.sun.hotspot.igv.view;
import com.sun.hotspot.igv.data.ChangedEvent;
import com.sun.hotspot.igv.data.ChangedListener;
import com.sun.hotspot.igv.data.GraphDocument;
import com.sun.hotspot.igv.data.Group;
import com.sun.hotspot.igv.data.InputNode;
import com.sun.hotspot.igv.data.InputBlock;
import com.lowagie.text.Document;
import com.lowagie.text.Rectangle;
import com.lowagie.text.pdf.PdfContentByte;
import com.lowagie.text.pdf.PdfGraphics2D;
import com.lowagie.text.pdf.PdfTemplate;
import com.lowagie.text.pdf.PdfWriter;
import com.sun.hotspot.igv.data.Properties;
import com.sun.hotspot.igv.data.*;
import com.sun.hotspot.igv.data.Properties.PropertyMatcher;
import com.sun.hotspot.igv.data.services.InputGraphProvider;
import com.sun.hotspot.igv.filter.FilterChain;
@ -37,16 +38,15 @@ import com.sun.hotspot.igv.filter.FilterChainProvider;
import com.sun.hotspot.igv.graph.Diagram;
import com.sun.hotspot.igv.graph.Figure;
import com.sun.hotspot.igv.graph.services.DiagramProvider;
import com.sun.hotspot.igv.settings.Settings;
import com.sun.hotspot.igv.util.LookupHistory;
import com.sun.hotspot.igv.util.RangeSlider;
import com.sun.hotspot.igv.settings.Settings;
import com.sun.hotspot.igv.view.actions.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.HierarchyBoundsListener;
import java.awt.event.HierarchyEvent;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import java.io.*;
@ -58,13 +58,6 @@ import javax.swing.border.Border;
import org.apache.batik.dom.GenericDOMImplementation;
import org.apache.batik.svggen.SVGGeneratorContext;
import org.apache.batik.svggen.SVGGraphics2D;
import com.lowagie.text.Document;
import com.lowagie.text.Rectangle;
import com.lowagie.text.pdf.PdfWriter;
import com.lowagie.text.pdf.PdfContentByte;
import com.lowagie.text.pdf.PdfTemplate;
import com.lowagie.text.pdf.PdfGraphics2D;
import org.w3c.dom.DOMImplementation;
import org.openide.DialogDisplayer;
import org.openide.NotifyDescriptor;
import org.openide.actions.RedoAction;
@ -79,11 +72,9 @@ import org.openide.util.actions.Presenter;
import org.openide.util.lookup.AbstractLookup;
import org.openide.util.lookup.InstanceContent;
import org.openide.util.lookup.ProxyLookup;
import org.openide.windows.Mode;
import org.openide.windows.TopComponent;
import org.openide.windows.WindowManager;
import org.w3c.dom.DOMImplementation;
import static java.nio.charset.StandardCharsets.UTF_8;
/**
*
@ -92,7 +83,6 @@ import static java.nio.charset.StandardCharsets.UTF_8;
public final class EditorTopComponent extends TopComponent implements PropertyChangeListener {
private DiagramViewer scene;
private Toolbar toolBar;
private InstanceContent content;
private InstanceContent graphContent;
private EnableSeaLayoutAction seaLayoutAction;
@ -110,16 +100,9 @@ public final class EditorTopComponent extends TopComponent implements PropertyCh
private RangeSlider rangeSlider;
private JToggleButton overviewButton;
private JToggleButton hideDuplicatesButton;
private static final Component quicksearch;
static {
Action searchAction = Utilities.actionsForPath("Actions/Search").get(0);
quicksearch = ((Presenter.Toolbar) searchAction).getToolbarPresenter();
Dimension preferredSize = quicksearch.getPreferredSize();
preferredSize = new Dimension((int) preferredSize.getWidth() * 2, (int) preferredSize.getHeight());
quicksearch.setMinimumSize(preferredSize); // necessary for GTK LAF
quicksearch.setPreferredSize(preferredSize);
}
private JPanel topPanel;
private Toolbar quickSearchToolbar;
private static final JPanel quickSearchPresenter = (JPanel) ((Presenter.Toolbar) Utilities.actionsForPath("Actions/Search").get(0)).getToolbarPresenter();
private static final String PREFERRED_ID = "EditorTopComponent";
private static final String SATELLITE_STRING = "satellite";
private static final String SCENE_STRING = "scene";
@ -208,9 +191,10 @@ public final class EditorTopComponent extends TopComponent implements PropertyCh
initComponents();
ToolbarPool.getDefault().setPreferredIconSize(16);
toolBar = new Toolbar();
Border b = (Border) UIManager.get("Nb.Editor.Toolbar.border"); //NOI18N
toolBar.setBorder(b);
Toolbar toolBar = new Toolbar();
toolBar.setBorder((Border) UIManager.get("Nb.Editor.Toolbar.border")); //NOI18N
toolBar.setMinimumSize(new Dimension(0,0)); // MacOS BUG with ToolbarWithOverflow
JPanel container = new JPanel();
this.add(container, BorderLayout.NORTH);
container.setLayout(new BorderLayout());
@ -324,9 +308,24 @@ public final class EditorTopComponent extends TopComponent implements PropertyCh
button.setSelected(false);
toolBar.add(button);
selectionModeAction.addPropertyChangeListener(this);
toolBar.add(Box.createHorizontalGlue());
toolBar.add(quicksearch);
quickSearchToolbar = new Toolbar();
quickSearchToolbar.setLayout(new BoxLayout(quickSearchToolbar, BoxLayout.LINE_AXIS));
quickSearchToolbar.setBorder((Border) UIManager.get("Nb.Editor.Toolbar.border")); //NOI18N
quickSearchPresenter.setMinimumSize(quickSearchPresenter.getPreferredSize());
quickSearchPresenter.setAlignmentX(Component.RIGHT_ALIGNMENT);
quickSearchToolbar.add(quickSearchPresenter);
// Needed for toolBar to use maximal available width
JPanel toolbarPanel = new JPanel(new GridLayout(1, 0));
toolbarPanel.add(toolBar);
topPanel = new JPanel();
topPanel.setLayout(new BoxLayout(topPanel, BoxLayout.LINE_AXIS));
topPanel.add(toolbarPanel);
topPanel.add(quickSearchToolbar);
container.add(BorderLayout.NORTH, topPanel);
centerPanel = new JPanel();
centerPanel.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT).put(
@ -457,12 +456,9 @@ public final class EditorTopComponent extends TopComponent implements PropertyCh
return TopComponent.PERSISTENCE_NEVER;
}
@Override
public void componentOpened() {
}
@Override
public void componentClosed() {
super.componentClosed();
rangeSliderModel.close();
}
@ -658,7 +654,6 @@ public final class EditorTopComponent extends TopComponent implements PropertyCh
@Override
protected void componentShowing() {
toolBar.add(quicksearch);
super.componentShowing();
scene.componentShowing();
}
@ -669,6 +664,13 @@ public final class EditorTopComponent extends TopComponent implements PropertyCh
scene.getComponent().requestFocus();
}
@Override
protected void componentActivated() {
super.componentActivated();
quickSearchToolbar.add(quickSearchPresenter);
quickSearchPresenter.revalidate();
}
@Override
public UndoRedo getUndoRedo() {
return scene.getUndoRedo();